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

Your Answer

8 + 5 =