Part 1 of 5 · 1 min read
Why this page comes first
In this module you will
- Write a scalar subquery and explain why it must return exactly one value.
- Write a correlated subquery and explain how it differs from an uncorrelated one.
- Choose between IN and EXISTS for a given query, with a reason.
- Rewrite a subquery-based query as an equivalent join, when one exists.
A single SELECT often cannot express a question that depends on another query's result. This page covers writing one query inside another. Reports need this constantly, to compare a row against some other, separately computed value.