查询出每个部门比平均工资高的职工人数输出部门号,部门名,人数的sql语句

2025-03-22 17:12:35
推荐回答(1个)
回答(1):

-- Oracle的EMP和DEPT表查询的,如有问题请继续追问
select e.deptno as "部门号",d.dname as "部门名",count(e.deptno) as "人数" from emp e, dept d where e.deptno = d.deptno and e.sal > (select avg(sal) from emp) group by e.deptno,d.dname;