Oracle分组函数之Grouping Sets

功能介绍:

自定义分组的字段

 

创建表:

View Code

 

插入测试数据:

View Code

 

Grouping Sets(null,t.classid,(t.classid,t.studentname)),类似于ROLLUP

Select t.classid,t.studentname,Sum(t.score) From Score t Group By Grouping Sets(null,t.classid,(t.classid,t.studentname)); 

 

查询结果:

 

Grouping Sets(null,t.classid,t.studentname,(t.classid,t.studentname)),类似于CUBE

Select t.classid,t.studentname,Sum(t.score) From Score t Group By Grouping Sets(null,t.classid,t.studentname,(t.classid,t.studentname)); 

 

查询结果:

 

posted @ 2015-06-25 18:04  大盗—如风  阅读(1294)  评论(0编辑  收藏  举报