您的位置:首页 > 数据库 > Oracle

列出各个部门中工资高于本部门的平均工资的员工数和部门号,并按部门号排序(oracle数据库中的emp表)

2017-10-18 14:35 4195 查看
列出各个部门中工资高于本部门的平均工资的员工数和部门号,并按部门号排序(测试表为oracle数据库中的emp表)

查询每个部门的平均工资

1,select deptno,avg(sal) from emp group by deptno;

查询工资高于本部门平均工资的员工和对应的员工编号,员工工资,部门编号

2,select e.empno,e.sal,e.deptno from emp  e,(select deptno,avg(sal) as asal from emp group by deptno) e1 where e.deptno=e1.deptno and e.sal>e1.asal;

查询每个部门中高于本部门平均工资的部门人数 和 [b]每个部门中[/b]工资高于本部门平均工资部门编号

3, select count(*),e.deptno from emp  e,(select deptno,avg(sal) as asal from emp group by deptno) e1 where e.deptno=e1.deptno
and e.sal>e1.asal group by e.deptno;

查询工资高于本部门平均工资部门编号 和 高于本部门平均工资的人数 并按部门号排序

4,select count(*),e.deptno from emp  e,(select deptno,avg(sal) as asal from emp group by deptno) e1 where e.deptno=e1.deptno and e.sal>e1.asal group by e.deptno order
by e.deptno;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐