select dept_no,emp_no,salary from (select dept_no,dept_emp.emp_no,salary,rank()over(partition by dept_no order by salary desc)rk from dept_emp join salaries on dept_emp.emp_no=salaries.emp_no) as a where a.rk=1 order by dept_no 直接用一个排序窗口函数就可以了,为什么好多用group by的