Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Top 3 Salaries in Each Department

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.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.