1、rollup
select job,sum(sal) from emp group by rollup(job);
將增加一行總的合計數。
2、cube
select job,deptno,sum(sal) from emp group by cube(job,deptno);
先按job和deptno的各種組合進行sum,最後一行爲總合計數。
3、grouping
select job,grouping(job),sum(sal) from emp group by rollup(job);
若job不爲空返回0,爲空值則返回1,
可據此判斷是否爲總合計行,也可用作order by。