SQL> select first_name,last_name,salary,department_id 2 from (select max(salary) over (partition by department_id) as max_salary, 3 first_name,last_name,salary,department_id 4 from hr.employees) a 5 where a.salary=max_salary and a.department_id is not null;