Learn / macOS

Learn SQL with lessons and practice

Use SQL worked examples, drills, and linked challenges to turn a language concept into a skill.

SQL learning with a lesson, worked examples, and query concepts.
SQL learning with a lesson, worked examples, and query concepts. Select the image to enlarge.
  1. Choose a concept

    Select a lesson on filtering, joins, grouping, or windows. Identify what one output row represents before writing a query.

    Example

    For a customer report, decide whether the result should contain one row per customer or one row per order.

  2. Trace and explain

    Trace the worked data through the query in logical steps and complete the drill. Look for nulls, duplicates, and empty groups.

    Example

    A LEFT JOIN retains a customer with no order. A WHERE condition on an order field can remove that row. Explain where the filter belongs.

  3. 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.

    Example

    Rank 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.