SQLSQL
#33

Find Employees Earning Above Department Average in SQL

MediumPwC
Interview Question #33
Asked at PwC

Given `employees` (emp_id, emp_name, department_id, salary), find all employees whose salary is strictly greater than the average salary of their respective department.

Input Table: employees
4 rows preview
emp_idemp_namedepartment_idsalary
1Sachin1085000
2Rahul1065000
3Shreya2095000
4Ananya2092000
Expected Output Structure2 rows
emp_idemp_namedepartment_idsalary
1Sachin1085000
3Shreya2095000
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us