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

Employees Earning More Than Department Average

Medium Subqueries

Return employees who earn more than the average salary of their own department. Return name, department_id and salary ordered by department_id, name.

Table schema

Employees(id INT PRIMARY KEY, name VARCHAR(50), department_id INT, salary INT)

Sample data

id | name | department_id | salary
1 | A | 1 | 100
2 | B | 1 | 200
3 | C | 2 | 50
4 | D | 2 | 50

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.