You are given an employees table with one row per employee, including their department and salary. For each department, return the employees whose salary is among the three highest salaries in that department.
Handle ties sensibly: employees who share the same salary should share the same ranking, and all employees within the top three salary levels of a department should be returned. This means a department can return more than three rows if several employees are tied at one of the top salary levels.
Return the columns department, name, salary, and rnk (the dense rank of the salary within the department, where 1 is the highest). Order the result by department ascending, then by salary descending, then by name ascending.