Först måste du få maxlönen för varje avdelning:
SELECT department, max(salary) as max_salary
FROM test
GROUP BY department
sedan kan du koppla tillbaka denna underfråga till testtabellen:
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