Listing 5: Query That Uses the RANK Function to Determine the Three Highest-Paid Employees in Each Department SELECT dept_id, last_name, salary, dept_rank FROM (SELECT dept_id, job, last_name, salary, RANK() OVER (PARTITION BY dept_id ORDER BY salary DESC) dept_rank FROM employee) AS part_dept WHERE dept_rank <= 3 ORDER BY dept_id, dept_rank