foundation Estimated learning time: 8 h

3.4 SQL for data work

You can pull your own data instead of asking someone for an extract.

Before:01. Mathematics for Machine Learning02. Python — Basics to AdvancedUnlocks:05. Classical Machine Learning

SQL is how data actually leaves databases, and an analyst who writes their own queries moves twice as fast as one waiting for extracts. Joins and window functions cover the great majority of practical needs. It sits in the data module because real projects start at a database, not a CSV. The classic confusion is NULL — it equals nothing, including itself, and half of all mysterious query results trace back to that one fact.

Work through these

  • SELECT, WHERE, GROUP BY, HAVING, ORDER BY

    The core query clauses, and the important detail that filtering before grouping and filtering after grouping are different operations. That distinction accounts for a large share of wrong query results.

  • Joins: inner, left, self, anti

    Combining tables, including joining a table to itself and finding rows that have no match. The last of those answers a surprising number of real questions.

  • Window functions: row_number, rank, lag, running totals

    Calculations that look across neighbouring rows without collapsing them, giving rankings, previous values and running totals. This is the feature that separates casual query writing from competent query writing.

  • CTEs, subqueries and query readability

    Named intermediate results and nested queries, and the fact that a readable query is a maintainable one. A query nobody can follow gets rewritten rather than reused.

Sign in to keep your progress.

Free resources

Links last checked 29 Aug 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.