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;

 

/ * -------- understand cube

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

group by cube( a, b, c)

 

Equivalent to

 

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

group by grouping sets(

( a, b, c ),

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

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

() )

*/

 

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11118927.html