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?
- A.A subquery that executes once before the outer query and caches its results.
- 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
- C.A subquery that contains a UNION operator linking multiple independent tables.
- 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
- Consider the query: SELECT FROM employees WHERE departmentid IN (SELECT departmentid FROM departments WHERE location = 'New York'); Which r…
- What is the primary operational difference between using the EXISTS operator with a correlated subquery versus using IN with a subquery?
- Explain the concept of a derived table (also known as an inline view) and state where it must be placed in a SQL query.
- Which of the following queries correctly uses a scalar subquery in the SELECT list to retrieve each employee's salary alongside the company…
Practise more SQL
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed