SELECT
    de.dept_no,
    de.emp_no,
    s.salary AS maxSalary
FROM
    dept_emp de
    JOIN salaries s ON de.emp_no = s.emp_no
WHERE
    s.to_date = '9999-01-01'
    AND s.salary = (
        SELECT
            MAX(s2.salary)
        FROM
            salaries s2
            JOIN dept_emp de2 ON s2.emp_no = de2.emp_no
        WHERE
            de2.dept_no = de.dept_no
            AND s2.to_date = '9999-01-01'
    )
ORDER BY
    de.dept_no;