Some questions can't be answered in a single pass — "which customers spent more than the average?" needs the average first. This module shows how to break complex questions into steps, starting with subqueries: queries nested inside other queries, in the WHERE, FROM, or SELECT clause.
You'll learn the difference between independent and correlated subqueries, how to test for matches with IN and EXISTS, and how common table expressions (the WITH clause) turn deeply nested logic into a readable sequence of named steps you can reuse within a query.
Work through the lessons in order, then continue on to Window Functions.
An introduction to nesting one query inside another, with worked examples of subqueries used for filtering.
Applies subqueries to a practical scenario so you can see why and when you would reach for one.
Another take on subqueries, helpful for seeing the same idea explained a second way before moving on.
A visual explanation of the WITH clause: how a CTE defines a temporary named result that the main query can use.
A walkthrough of writing and using CTEs to simplify queries that would otherwise be hard to read.
Hands-on CTE examples, including turning a nested query into a clearer, step-by-step one.