题解 | #获取每个部门中当前员工薪水最高的相关信息#
获取每个部门中当前员工薪水最高的相关信息
http://www.nowcoder.com/practice/4a052e3e1df5435880d4353eb18a91c6
利用row_number()对部门分组并按薪水排序,然后取row_n=1的部门编号,员工编号,薪水
select b.dept_no, b.emp_no, b.salary from
(select *, row_number() over (partition by r.dept_no order by r.salary desc) as row_n from
(select d.dept_no,d.emp_no,s.salary from salaries s, dept_emp d where d.emp_no = s.emp_no) as r
) as b
where row_n = 1;