题解 | #获取每个部门中当前员工薪水最高的相关信息#
获取每个部门中当前员工薪水最高的相关信息
http://www.nowcoder.com/practice/4a052e3e1df5435880d4353eb18a91c6
SELECT a.dept_no, a.emp_no, a.salary as maxSalary
FROM (
select d.dept_no, d.emp_no, s.salary
,RANK()over(partition by d.dept_no order by s.salary DESC) as rk
FROM dept_emp as d, salaries as s
WHERE d.emp_no = s.emp_no
and d.to_date='9999-01-01'
and s.to_date='9999-01-01'
) AS a
where rk ='1'