Per prima cosa devi ottenere lo stipendio massimo per ogni reparto:
SELECT department, max(salary) as max_salary
FROM test
GROUP BY department
quindi puoi unire nuovamente questa sottoquery alla tabella di test:
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