题解 | 获取每个部门中薪水最高的员工相关信息
SELECT dept_no,emp_no,salary FROM (SELECT A.EMP_NO,DEPT_NO,SALARY,ROW_NUMBER() OVER(PARTITION BY DEPT_NO ORDER BY SALARY DESC) AS RK FROM dept_emp A LEFT JOIN salaries B ON A.EMP_NO = B.EMP_NO) A WHERE RK = 1 ORDER BY DEPT_NO