题解 | #获取每个部门中当前员工薪水最高的相关信息#

获取每个部门中当前员工薪水最高的相关信息

http://www.nowcoder.com/practice/4a052e3e1df5435880d4353eb18a91c6

select b.dept_no,b.emp_no,b.salary
from
(select de.dept_no,de.emp_no,s.salary from dept_emp de join salaries s ON de.emp_no=s.emp_no
where de.to_date='9999-01-01' and s.to_date='9999-01-01') b
where (b.dept_no,b.salary) IN (select c.dept_no,max(c.salary) as salary
from (select de.dept_no,de.emp_no,s.salary
from dept_emp de join salaries s ON de.emp_no=s.emp_no
where de.to_date='9999-01-01' and s.to_date='9999-01-01') c
group by c.dept_no)
order by b.dept_no

全部评论

相关推荐

1 收藏 评论
分享
牛客网
牛客企业服务