【Oracle】ROLLUP和CUBE的“小计”功能

前端之家收集整理的这篇文章主要介绍了【Oracle】ROLLUP和CUBE的“小计”功能前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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);

猜你在找的Oracle相关文章