当前位置 : 主页 > 手机开发 > ROM >

oralce GROUPING SETS

来源:互联网 收集:自由互联 发布时间:2021-06-10
select id,area,stu_type,sum(score) score from students group by grouping sets((id,area,stu_type),(id,area),id) order by id,area,stu_type; /*--------理解grouping sets select a, b, c, sum( d ) from t group by grouping sets ( a, b, c ) 等效于

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

from students

group by grouping sets((id,area,stu_type),(id,area),id)

order by id,area,stu_type;

 

/*--------理解grouping sets

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

group by grouping sets ( a, b, c )

 

等效于

 

select * from (

select a, null, null, sum( d ) from t group by a

union all

select null, b, null, sum( d ) from t group by b

union all

select null, null, c, sum( d ) from t group by c

)

*/

上一篇:存储过程实例
下一篇:第二章 数字类型
网友评论