MYSQL:

SELECT X.dept_no,salaries.emp_no,X.maxSalary
FROM salaries JOIN dept_emp 
ON salaries.emp_no=dept_emp.emp_no
JOIN
(SELECT dept_emp.dept_no,MAX(salaries.salary) AS maxSalary
FROM dept_emp JOIN salaries
ON dept_emp.emp_no=salaries.emp_no
GROUP BY dept_no) X
ON salaries.salary=X.maxSalary AND dept_emp.dept_no=X.dept_no
ORDER BY dept_no;

 

posted on 2021-10-12 11:05  Sempron2800+  阅读(45)  评论(0编辑  收藏  举报