请教:关于 with rollup 的问题
select a1=isnull(a1, '合计 '),a2,count(*)
from table
group by a1,a2 with rollup
执行上面语句,最后一行有 "合计 ",而执行下面语句,却没有 "合计 ":
select a1=isnull(a1+ '- '+a2), '合计 '),count(*)
from table
group by isnull(a1+ '- '+a2), '合计 ') with rollup
请问第2条语句该怎样写?
------解决方案--------------------select a1=case when grouping(a1+ '- '+a2)=1 then '合计 ' end,count(*)
from table
group by (a1+ '- '+a2) with rollup
------解决方案--------------------select a1=isnull(x, '合计 '),count(*)
from (
select a1+ '- '+a2 as x
from table
) as t
group by x with rollup