Highest Paid Employee in Each Department
Medium
Subqueries
For every department return the employee(s) with the highest salary, including ties. Return department_id, name and salary ordered by department_id, then 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 | 70000
2 | Jim | 1 | 90000
3 | Henry | 2 | 80000
4 | Sam | 2 | 60000
5 | Max | 1 | 90000
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.