标签:sele rollup group by order by sub ring group substring select
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.日期
标签:sele rollup group by order by sub ring group substring select
原文地址:http://blog.51cto.com/gongxi/2287384