排列顺序:小计、总计、合计。共计分开使用。
小计:小计就是简单核算一下单个体,可理解为日小计
合计:合计就是把所有小计加起来,可理解为月合计
总计:总计就是把合计加起来,可理解为年总计
共计:一组数字的总和。一般是几个类型的东西的合计数。
一句sql,将明细,小计,合计,总计都查了
select x1,x2,x3... from (
with mx as (
select x1,x2,x3,(select x4 from m where ... and rownum <2 ) x4,...
from x,y,z
where ...
)
select x1,x2,x3... from mx
union all
select x1,
x2,
'' x3,
...
sum(x7) x7,
sum(x8) x8,
sum(x9) hj
from mx
group by ROLLUP(x1, x2)
) t
order by x1,x2,x3...