Problem Statement
Which option best describes a correlated subquery?
Explanation
A correlated subquery depends on the current row of the outer query. The database must re-evaluate it for each outer row.
This design is expressive, but can be slow if the inner expression is not selective or not indexed. Many engines can transform it into a join when the logic allows.
Code Solution
SolutionRead Only
SELECT e.emp_id FROM employees e WHERE e.salary > ( SELECT AVG(salary) FROM employees x WHERE x.dept_id = e.dept_id );
Practice Sets
This question appears in the following practice sets:
