Top 3 Salaries in Each Department
Hard
Window Functions
Find the employees who earn one of the three highest distinct salaries in their department. Return department_id, name and salary ordered by department_id, salary descending, name.
Table schema
Employees(id INT PRIMARY KEY, name VARCHAR(50), department_id INT, salary INT)Sample data
id | name | department_id | salary
1 | Joe | 1 | 85000
2 | Henry | 1 | 80000
3 | Sam | 1 | 60000
4 | Max | 1 | 90000
5 | Janet | 1 | 69000
6 | Randall | 1 | 85000
7 | Will | 2 | 70000
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.