oracle中emp表查询每个部门中,超过部门平均工资的员工姓名。

2025-03-23 06:29:37
推荐回答(3个)
回答1:

用连查

回答2:

select * from (
select emp.*, avg(emp.sal) over (partition by emp.deptid) as avgsal
from emp) a
where a.sal>a.avgsal
order by emp.deptid;

回答3:

select a.* from emp a, (select deptno, avg(sal) sav from emp group by deptno) b
where a.deptno = b.deptno and a.sal > b.sal