oralce CUBE

select id,area,stu_type,sum(score) score

from students

group by cube(id,area,stu_type)

order by id,area,stu_type;

 

/*--------理解cube

select a, b, c, sum( d ) from t

group by cube( a, b, c)

 

等效于

 

select a, b, c, sum( d ) from t

group by grouping sets(

( a, b, c ),

( a, b ), ( a ), ( b, c ),

( b ), ( a, c ), ( c ),

() )

*/

 

posted @ 2019-07-02 10:18  樊伟胜  阅读(102)  评论(0编辑  收藏  举报