oracle查询

今天碰到的难题

1、查询每个部门的平均薪水,之后显示部门平均薪水大于2000的部门编号和其平均薪水
   select deptno,avg(sal) from emp group by deptno having avg(sal)>2000;
 

 2.查询在平均薪水大于2000的部门中薪水大于3000的员工所在部门编号,部门平均薪水


select deptno,avg(sal)
from emp
where deptno in
    (select deptno
     from emp group by deptno having avg(sal)>2000)
   and sal>3000
group by deptno;


posted @ 2017-11-18 15:59  空城花开  阅读(129)  评论(0编辑  收藏  举报