綜合查詢(5)--選擇參考模組
什麼是基準模組。就是你的綜合查詢要以哪個模組作為查詢的主模組,我沒想到其它的詞,就用這個來表示一下。詳細的來說。就是你選擇了若干個模組的欄位組成了一個查詢,你究競是想展示哪個模組的內容。比方我們前幾節的樣例中,選擇的模組有“訂單”和“訂單明細”,裡面有分別以“訂單”和“訂單明細”作為基準模組的截圖。如今來詳細講講二個父子模組作為基準模組時的不同之處。
1、子模組作為基準模組:這時全部的父模組的欄位都會增加。
查詢的sql 語句為:
select // 訂單明細的欄位 _t6050.tf_ordersDetailId as tf_ordersDetailId , _t6050.tf_name as tf_name , _t6050.tf_number as tf_number , _t6050.tf_unitPrice as tf_unitPrice , _t6050.tf_subtotalPrice as tf_subtotalPrice , _t6050.tf_remark as tf_remark , //訂單的欄位 _t6040.tf_date as _t6040___tf_date , _t6040.tf_finished as _t6040___tf_finished , _t6040.tf_ordersId as _t6040___tf_ordersId , _t6040.tf_ordersNumber as _t6040___tf_ordersNumber , from OrdersDetail _t6050 //訂單明細 left outer join Orders _t6040 //訂單 on _t6040.tf_ordersId = _t6050.tf_ordersId
2、當以父模組作為基準模組時。子模組的記錄就僅僅能以聚合欄位的形式出現了。沒有聚合操作的欄位將會被捨去。
生成的sql 語句為:
select //訂單資訊 _t6040.tf_ordersId as tf_ordersId , _t6040.tf_ordersNumber as tf_ordersNumber , _t6040.tf_date as tf_date , _t6040.tf_finished as tf_finished , _t6040.tf_remark as tf_remark , //訂單明細的數量彙總 ( select sum(_t6050.tf_number) from OrdersDetail _t6050 left outer join Orders _child_t6040 on _child_t6040.tf_ordersId = _t6050.tf_ordersId where _child_t6040.tf_ordersId = _t6040.tf_ordersId ) as S__t6050___tf_number , //訂單明細的金額彙總 ( select sum(_t6050.tf_subtotalPrice) from OrdersDetail _t6050 left outer join Orders _child_t6040 on _child_t6040.tf_ordersId = _t6050.tf_ordersId where _child_t6040.tf_ordersId = _t6040.tf_ordersId ) as S__t6050___tf_subtotalPrice from Orders _t6040
上面的樣例裡僅僅出現了求和的聚合操作。那麼假設要增加計數,最大值,最小值,平均值要怎樣操作呢。前面幾節在介紹選擇欄位。輸入欄位的條件時,在條件值的以下有5個checkbox ,用來設定該欄位。能夠生成哪些個聚合的欄位。
確定後執行後。我們來看看查詢結果:
sql語句和上面的類似就是增加了count ,max ,min,avg 等。這個介面上以後還能增加擴充套件功能。比方說在“數量個數”的值上加個連結,一點就能看到明細;在“數量最大值”的值上加個連結,一點就能檢視最大值的那個“訂單明細”等等。
版權宣告:本文博主原創文章,部落格,未經同意不得轉載。