Before you start
You need Workbench and a running SQL engine. Every example includes its own input rows. No catalog, files, credentials, or external data is needed. These queries create no stored tables. Copy the SQL into Workbench and run the statements in order. Compare the result with the table below the query.WITH names input data for one statement only. Each example can run on its own.
1. Match rows
Who placed each known order?
INNER JOIN keeps matching pairs.
Change one thing: Add WHERE c.name = ‘Ada’. Expect orders 10 and 11.
2. Keep every customer
Which customers have orders?
LEFT JOIN keeps a left row even when no right row matches.
Change one thing: Filter WHERE s.order_id IS NULL. Only Cy remains.
3. Find unknown customers
Which order has no known customer?
A null in the matched key marks an unmatched row.
Change one thing: Use WHERE c.id IS NOT NULL. Expect orders 10, 11, and 12.
4. Keep customers with orders
Which customers have at least one order?
A semi join returns matching left rows once.
Change one thing: Add WHERE c.id = 1. Only Ada remains.
5. Keep customers without orders
Which customers have no orders?
An anti join keeps left rows with no match.
Change one thing: Use LEFT SEMI JOIN instead. Expect Ada and Ben.
6. Build all combinations
How many customer and channel pairs exist?
A cross join produces every pair. Repeated join keys also produce multiple pairs.
Change one thing: Keep only Email in the channel input. Expect three rows.