题解 | 获取每个部门中薪水最高的员工相关信息
SELECT dept_no,emp_no,salary FROM( SELECT b.dept_no,a.emp_no,a.salary,RANK() OVER(partition by b.dept_no order by a.salary DESC) s_rank FROM salaries a LEFT JOIN dept_emp b ON a.emp_no = b.emp_no) AS a WHERE s_rank = 1 ORDER BY dept_no