两个部门查询最高工资所在部门的最低工资sql怎么写

2025-03-22 17:22:31
推荐回答(3个)
回答1:

select min(sal) from scott.emp where deptno in
(
select deptno from scott.emp where sal in
(select max(sal) from scott.emp)
)

select distinct(deptno),min(sal) over (partition by deptno order by sal asc) sal from scott.emp where deptno in (select deptno from (select deptno from scott.emp order by sal desc) where rownum<=1)

回答2:

select 部门表.*
from 部门表 inner join 人员部门表
on 部门表.部门 = 人员部门表.部门
where 人员部门表.人员 in (select top 1 人员 from 人员工资 order by 工资 desc)

回答3:

select top 1 工资 from 表 where 部门 = (select top 1 部门 from 表
order by 工资 desc) order by 工资