慕课网笔记(增强型 group by )

分组函数的嵌套
目的:求部门平均工资的最大值

select max(avg(sal)) from emp group by deptno;

GROUP BY 语句的增强

select deptno,job,sum(sal) from emp group by deptno,job order by deptno;
select sum(sal) from emp group by deptno;
select sum(sal) from emp;

以上等于

select deptno,job,sum(sal) from emp group by rollup(deptno,job);
group by rollup(a,b)
等价于:
group by a,b
+
group by a
+
group by null

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章