group by 子句oracle实现

来源:互联网 发布:landsat5数据预处理 编辑:程序博客网 时间:2024/05/21 04:22

1.查询部门平均工资在2000元以上的部门名称及平均工资。

select emp.deptnofrom emp,deptwhere emp.deptno=dept.deptnogroup by emp.deptnohaving avg(sal)>2000;


 

 

2.查询部门人数在4人以上的部门的部门名称及最低工
    资和最高工资。

select dept.dname,min(sal),max(sal)from emp,deptwhere emp.deptno=dept.deptnogroup by dept.dnamehaving count(empno)>4