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

Your Answer

17 + 1 =