Select ID,name,no,
(Case When Kind Is null And ID Is Null Then '总计:'
When ID Is Null Then '小计:' Else Kind End) As Kind,
Sum(jine) jine,class
From 表名
Group By Grouping Sets((id,name,no,kind,class),(kind),())
select kind,jine,sum(jine),grouping(kind) from 表名 group by kind,jine with ROLLUP 这么写就可以了