select dept_no,emp_no,salary as maxSalary from( select dept_no,d.emp_no,salary,rank() over(partition by dept_no order by salary desc) as r from dept_emp as d left join salaries as s on d.emp_no=s.emp_no) as n where r=1 使用窗口函数