题解 | #获取每个部门中薪水最高的员工相关信息#
获取每个部门中薪水最高的员工相关信息
https://www.nowcoder.com/practice/4a052e3e1df5435880d4353eb18a91c6
SELECT a.dept_no,a.emp_no,a.salary FROM( SELECT de.emp_no,dept_no,salary FROM dept_emp de JOIN salaries s USING (emp_no) ) a WHERE a.salary= (SELECT MAX(salary) FROM ( SELECT de.emp_no,dept_no,salary FROM dept_emp de JOIN salaries s USING (emp_no) ) b WHERE b.dept_no=a.dept_no) ORDER BY a.dept_no