Subqueries · SQL SQL

Which of the following best describes a correlated subquery?

Practice question from Subqueries (SQL SQL), with the correct answer and a step-by-step solution.

medium · MCQ · Q-FD17B9

Which of the following best describes a correlated subquery?

  1. A.A subquery that executes once before the outer query and caches its results.
  2. B.A subquery that depends on values from the outer query and must be evaluated for each row processed by the outer query.Correct answer
  3. C.A subquery that contains a UNION operator linking multiple independent tables.
  4. D.A subquery that can only be used within the FROM clause as a derived table.

Solution

A correlated subquery references columns from the outer query. Because of this dependency, the database engine typically evaluates the subquery separately for every candidate row examined by the outer query.

More from Subqueries

All of Subqueries

Practise more SQL

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed