Top Two Salaries per Department With Ties
Medium
Ranking Edge Cases
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.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.