
Choose a concept
Select a lesson on filtering, joins, grouping, or windows. Identify what one output row represents before writing a query.
ExampleFor a customer report, decide whether the result should contain one row per customer or one row per order.
Trace and explain
Trace the worked data through the query in logical steps and complete the drill. Look for nulls, duplicates, and empty groups.
ExampleA LEFT JOIN retains a customer with no order. A WHERE condition on an order field can remove that row. Explain where the filter belongs.
Apply it in practice
Open a linked exercise in Data Practice and choose SQL. Run a small query first, then add grouping or windows and submit when visible checks pass.
ExampleRank orders within each customer. Check how ties should behave and whether the prompt needs one rank, dense ranks, or a row number.
Check your work
You can explain a worked example and use the same rule on a new input or exercise.
Try it yourself
Imagine customers A and B. A has two orders and B has none. After a left join grouped by customer, compare COUNT(*) with COUNT(orders.id), assuming orders.id is never null in the orders table.
- What to look for
- COUNT(*) counts the placeholder row for B, giving 1. COUNT(orders.id) gives 0 for B and 2 for A. Use the count that matches the requested output.