[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
MockInterview Staff asked 12 months ago
2 Answers
MockInterview Staff answered 12 months ago
SELECT employee_number, name
   FROM employees emp
   WHERE salary > (
     SELECT AVG(salary)
       FROM employees
       WHERE department = emp.department);

Your Answer

16 + 15 =