ROLLUP和CUBE都是“小计”功能。
配合上GROUP BY,可以进行分组小计。
配合例子进行说明:
SELECT * FROM GROUP_TEST G;
SELECT G.GROUP_ID,SUM(G.SALARY) FROM GROUP_TEST G GROUP BY G.GROUP_ID;
SELECT G.GROUP_ID,SUM(G.SALARY) FROM GROUP_TEST G GROUP BY ROLLUP(G.GROUP_ID);
SELECT G.GROUP_ID,G.JOB,SUM(G.SALARY) FROM GROUP_TEST G GROUP BY ROLLUP(G.GROUP_ID,G.JOB);
SELECT G.GROUP_ID,SUM(G.SALARY) FROM GROUP_TEST G GROUP BY CUBE(G.GROUP_ID,G.JOB);