如何将结果合计为一个记录而不是多个item_id实例。相反,我需要为每个项目开具发票总额。
查询结果 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
答案 0 :(得分:1)
试试这个,如果您需要更多信息,请告诉我
select
inv_mast.item_id,SUM(oe_line.qty_invoiced)
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'
GROUP BY inv_mast.item_id
order by
inv_mast.item_id