Correlated subquery for per-row condition
SQL
Easy
2 views
Problem Description
List employees who earn more than the average salary of their own department.
Sample Test Case
Input:
Employees(dept_id, salary)
Constraints
Correlated avg
Official Solution
SELECT e.emp_id, e.name, e.salary FROM Employees e WHERE e.salary > (SELECT AVG(salary) FROM Employees x WHERE x.dept_id = e.dept_id);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!