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

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.

Rewards ยท v2.1

Join Shalyam Newsletter

Get exclusive insights with every issue: education, research and innovation news.

One email a week. Unsubscribe any time.