select tt.dept_no, tt.emp_no, tt.salary
from
(select dp.*, ss.salary, dense_rank() over(partition by dp.dept_no order by ss.salary desc) as dr 
from dept_emp dp join salaries ss on dp.emp_no = ss.emp_no
where dp.to_date = '9999-01-01') tt
where tt.dr = 1