不知道你所谓小计是什么意思,你可以看看下面的效果select case when ID is null then '合计'
when CODE is null then'小计'else to_char(ID) end,CODE,totalfrom ( select ID,CODE,sum(NUMBER) total from tttt group by rollup(ID,CODE) )如果不是上面的意思 那么用开窗函数看看SELECTID,CODE,NUMBERsum(NUMBER) OVER(partition byID,CODE ORDER BY NUMBER R... |