[SQL] use correlated subquery to find all employees whose salary is above average for their department

Data Science Interview QuestionsCategory: Data Science[SQL] use correlated subquery to find all employees whose salary is above average for their department
2 Answers
MockInterview Staff answered 7 months ago
SELECT employee_number, name
   FROM employees emp
   WHERE salary > (
     SELECT AVG(salary)
       FROM employees
       WHERE department = emp.department);

[Content Sponsor] $750 discount on any springboard courses including Data Science Career Track which comes with a Job Guarantee!

Your Answer

5 + 7 =

Data Science Career Bootcamp