まず、各部門の最大給与を取得する必要があります:
SELECT department, max(salary) as max_salary
FROM test
GROUP BY department
次に、このサブクエリをテストテーブルに結合し直すことができます:
SELECT t.*
FROM
test t INNER JOIN (
SELECT department, max(salary) as max_salary
FROM test
GROUP BY department
) d ON t.department=d.department AND t.salary=d.max_salary