功能介绍:
自定义分组的字段
创建表:
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));
查询结果: