cube分组
cube分组会对后面列的所有组合情况进行group by,而不像rollup那样从右到左依次递减
-- 语法结构
select ... group by cube(column1, column2, ...);
-- 将rollup换成cube
select a.dname, b.job, sum(b.salary)
from dept a, emp b
where a.deptno = b.deptno
group by rollup(a.dname, b.job)
上述例子,rollup依次分组:
group by(dname, job)
group by(dname, null)
group by(null, null)
上述例子,cube分组:
group by(dname, job)
group by(dname, null)
group by(null, null)
group by(null, job) – 此例, cube比rollup多出这个分组