Problem Statement
Which statement best distinguishes a correlated subquery from a non-correlated subquery?
Explanation
A correlated subquery depends on values from the current row of the outer query, so the database re-evaluates it for each outer row. That makes it expressive but potentially slower on large inputs.
A non-correlated subquery is independent and runs once, with its result reused. It is easier for optimizers to transform into joins or set operations.
Code Solution
SolutionRead Only
SELECT e.* FROM employees e WHERE e.salary > ( SELECT AVG(salary) FROM employees x WHERE x.dept_id = e.dept_id );
