Tutorials

Guided paths through the reference, in the order worth learning them. Every step links to a full page with runnable examples — nothing here is new content, just a map through what already exists.

Track 1

SQL fundamentals

Start here if WHERE, GROUP BY, and JOIN are still a little shaky. Each step builds on the last.

  1. 1
    NULL handling

    The three-valued logic that shapes everything downstream.

  2. 2
    WHERE

    Filtering rows before anything else happens.

  3. 3
    DISTINCT

    Removing duplicates — and why it applies to the whole row.

  4. 4
    ORDER BY

    Making result order deterministic and intentional.

  5. 5
    GROUP BY

    Collapsing rows into groups.

  6. 6
    HAVING

    Filtering groups, after they’re formed.

  7. 7
    CASE

    Branching logic inside a query.

  8. 8
    INNER JOIN

    Combining rows that match in both tables.

  9. 9
    LEFT JOIN

    Keeping every row from one side, matched or not.

Track 2

Window functions

For once WHERE/GROUP BY/JOIN feel natural. Window functions unlock a whole class of "rank within a group" and "running total" problems.

  1. 1
    The complete guide to window functionsGuide

    Start with the narrative — OVER(), PARTITION BY, and how ranking, running totals, and frames all fit together.

  2. 2
    ROW_NUMBER

    One row per group, no duplicates — the base for top-N-per-group.

  3. 3
    RANK / DENSE_RANK

    Ranking with ties — two different tie-breaking rules.

  4. 4
    Running total

    A windowed SUM that keeps row-level detail.

  5. 5
    LAG / LEAD

    Comparing a row to the one before or after it, no self-join.

  6. 6
    Window frames

    Controlling exactly which rows a window aggregate sees.

Track 3

Writing and protecting data

Everything above reads data. This is how it changes — safely.

  1. 1
    INSERT

    Single row, multi-row, and INSERT … SELECT.

  2. 2
    UPDATE

    Changing existing rows — and the WHERE clause that stops it from changing every row.

  3. 3
    DELETE

    Removing rows, and how it differs from TRUNCATE.

  4. 4
    BEGIN, COMMIT, ROLLBACK

    Grouping statements so they succeed or fail together.

  5. 5
    Isolation levels

    What one transaction can see of another running at the same time.

Track 4

Diagnosing a query that’s wrong

The query runs, but the result is wrong, or a rule you swore was true just broke. Start with the symptom that matches.

  1. 1
    Why your query returns the wrong number of rowsGuide

    A join multiplying rows, or a WHERE silently undoing a LEFT JOIN.

  2. 2
    NULL in SQL: the complete guideGuide

    Why a query that looks right returns nothing, or a comparison you expected to fail just vanished.

  3. 3
    EXISTS and IN

    The NOT IN + NULL trap that returns zero rows with no error.

  4. 4
    Type coercion

    Why a comparison or sort gives a different answer than expected.

  5. 5
    The order SQL actually runs inGuide

    Why WHERE can’t see a SELECT alias, and other order-of-execution errors.

  6. 6
    Query Doctor

    Paste the broken query and its error — get the root cause and a fix.

Track 5

Performance basics

Once queries are correct, make them fast — and prove it.

  1. 1
    Indexes

    What an index does, and the patterns that silently defeat one.

  2. 2
    Reading query plans

    EXPLAIN across engines — what a scan vs. a search actually means.

Prefer to look something up directly? Open the cheat sheet or browse the full reference.