27,579
社区成员
发帖
与我相关
我的任务
分享
-- 先查询出每个部门的最高工资:
select 部门,max(工资) as 最高工资
from 工资表
group by 部门
-- 然后呢?
select * from tb a
where not exists (select 1 from tb where 部门=a.部门 and 员工<>a.员工 and 工资>a.工资)
select * , 工资 = (select max(工资) from tb where 员工ID = t.员工ID) from tb t