Difficulty: Easy
Correct Answer: Incorrect (in a correlated subquery, the inner query references the outer row)
Explanation:
Introduction / Context:
SQL supports non-correlated and correlated subqueries. Distinguishing them helps predict performance and correctness. This question probes whether you know which side references which in correlation: does the inner query refer to the outer, or does the outer depend on the inner in a special way?
Given Data / Assumptions:
Concept / Approach:
A correlated subquery is one where the inner subquery references columns from a row of the outer query. Because of this dependency, the inner subquery is re-evaluated for each outer row to which it is correlated. While it is true that the outer result uses the subquery’s outcome, correlation specifically refers to the direction of reference: the inner referencing the outer. Therefore, stating that correlation is defined by the outer depending on the inner’s data is imprecise and, as a definition, incorrect.
Step-by-Step Solution:
Verification / Alternative check:
Compare with a non-correlated subquery: WHERE col IN (SELECT col FROM T). The inner has no reference to the outer; it runs once and the result is reused, unlike a correlated subquery.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming any subquery is correlated; ignoring performance implications because correlated subqueries often evaluate many times, one per outer row.
Final Answer:
Incorrect (in a correlated subquery, the inner query references the outer row)
Discussion & Comments