select dept_no, t1.emp_no, maxSalary
from(select dept_no, t1.emp_no, salary as maxSalary,
rank() over(partition by dept_no order by salary desc) as rk
from salaries t1 left join dept_emp t2 using(emp_no)) t1
where rk =1