如何將我的結果總計爲一條記錄而不是item_id的多個實例。相反,我需要爲每件商品開具總數量的發票。如何總計SQL結果
查詢結果 http://i.imgur.com/uakv7e5.jpg
select
inv_mast.default_product_group,
inv_mast.item_id,
inv_mast.item_desc,oe_hdr.order_date,
oe_line.qty_invoiced,
oe_line.extended_price
from
job_price_hdr
join oe_hdr on oe_hdr.job_price_hdr_uid = job_price_hdr.job_price_hdr_uid
join oe_line on oe_line.order_no = oe_hdr.order_no
join inv_mast on inv_mast.inv_mast_uid = oe_line.inv_mast_uid
where
oe_line.qty_invoiced> 0
and
oe_hdr.customer_id = 100080
and
default_product_group = 'FAST'
order by
inv_mast.item_id
SQL有一個sum()函數。你知道如何使用它嗎? – 2014-11-06 17:08:07
只是學習它。 – eggwhites 2014-11-06 17:12:25