1. 程式人生 > >月度出貨數量及金額

月度出貨數量及金額

sele select and 日期 left 總計 sub HERE pre

use TEST go select * from ( select isnull(SUBSTRING(a.TG003,1,6),‘總計:‘) as 日期,sum(b.TH008) as 數量,sum(b.TH013)as 金額 from COPTG as a left join COPTH as b on a.TG001+a.TG002=b.TH001+b.TH002 left join INVMB as c on b.TH004 = c.MB001 where a.TG003 like ‘2018%‘ and c.MB005 = ‘101‘ GROUP BY SUBSTRING(a.TG003,1,6) with rollup ) as a ORDER BY a.日期

月度出貨數量及金額