Oracle ROLLUP和CUBE 用法
CUBE和ROLLUP ROLLUP是Oracle8i以来一个新的SQL关键字,9i ,-11G不新鲜了,它是对GROUP BY子句的扩充,允许在SELECT语句中计算不同层次的小计。
CUBE是对GROUP BY子句的另外一 种扩充,它允许计算所有小计可能的组合,用来生成各种汇总报表。
以下介绍他们的用法
select B,c,D from Atest group by rollup(B,C,D);
相当于
select B,c,D from Atest group by B,C,D;
union all
select B,c,null from Atest group by B,C
union all
select B,null,null from Atest group by B
select B,c from Atest group by cube(B,C);
将所有 (B,C)组合的子集group by合并
相当于
select B,c from Atest group by B,C
union all
select B,null from Atest group by B
union all
select null,c from Atest group by c
union all
select null,null from Atest group by null
相关推荐
oraclemch 2020-11-06
Seandba 2020-08-16
dbasunny 2020-08-16
娜娜 2020-06-22
专注前端开发 2020-10-21
苏康申 2020-11-13
vitasfly 2020-11-12
liuyang000 2020-09-25
FellowYourHeart 2020-10-05
赵继业 2020-08-17
whyname 2020-08-16
拼命工作好好玩 2020-08-15
langyue 2020-08-15
写程序的赵童鞋 2020-08-03
Accpcjg 2020-08-02
tydldd 2020-07-30
好记忆也需烂 2020-07-28