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

Top Two Salaries per Department With Ties

Return employees whose salary is among the top two distinct salaries of their department. Order by dept, salary descending, name.

Table schema

Employees(id INT PRIMARY KEY, name VARCHAR(10), dept VARCHAR(10), salary INT)

Sample data

id | name | dept | salary
1 | Ann | IT | 100
2 | Bob | IT | 100
3 | Cy | IT | 80
4 | Dee | IT | 60
5 | Eli | HR | 50
6 | Fay | HR | 40

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.