How to explain the subtotal total?

Arrangement order: subtotal, total, total. Totally used separately.

Subtotal: The subtotal is a simple calculation of a single body, which can be understood as a daily subtotal

Total: Total is to add up all subtotals, which can be understood as monthly totals

Total: Total is to add up total, which can be understood as annual total

Total: The sum of a set of numbers. Generally it is the sum of several types of things.

 

One sentence of sql, check the details, subtotals, totals, and totals

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...

 

Guess you like

Origin blog.csdn.net/zengmingen/article/details/107299914