#思路:①用窗口函数选出每个部门在职员工最高薪水;②选出最高薪水对应的员工相关信息即可。

select dept_no, emp_no, maxSalary
from(
select dept_no, emp_no, salary, 
max(salary)over(partition by dept_no) maxSalary
from dept_emp join salaries using(emp_no)
where dept_emp.to_date='9999-01-01'
) as tb1
where maxSalary=salary