日期:2014-05-16  浏览次数:20397 次

Oracle cube rollup 区别


?rollup()合计函数,求合计

cube ()合计函数 比前一个更详细

例子(也可以叫交叉报表交叉报表)

create table test(sales varchar2(10),dest varchar2(10),revenue number)
insert into test values('smith','hangzhou',1000);
insert into test values('smith','wenzhou',2000);
insert into test values('allen','wenzhou',3000);
insert into test values('allen','wenzhou',4000);

SELECT sales, nvl(dest,'合计'), SUM(revenue) FROM test GROUP BY CUBE(sales, dest);





SELECT sales, nvl(dest,'合计'), SUM(revenue) FROM test GROUP BY ROLLUP(sales, dest);



?



比CUBE少2原因是没有对hangzhou、wenzou 的综合进行统计

?