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

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

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