all tracks

~/learn/sql

SQL curriculum

Joins, aggregation, window functions on a live SQLite database.

SELECT → filter → group → join → rank

0 / 18 lessons completed

Start with SELECT queries

Milestone 1 · Foundations

Beginner

Start here — the syntax and mental models everything else builds on.

  1. 1

    Query basics

    ~5 min · 1 lesson

    Pull exactly the columns you need out of any table.

    SELECTFROMASDISTINCT
  2. 2

    Filtering & sorting

    ~14 min · 2 lessons

    Find the rows that matter — e.g. UK customers who signed up this year, newest first.

    WHEREORDER BYLIMITIS NULL
  3. 3

    Aggregation

    ~8 min · 1 lesson

    Answer business questions like total sales per country or average order value.

    COUNTSUMAVGGROUP BYHAVING

Milestone 2 · Real-world data

Intermediate

Combine data from several places and reshape it into answers.

  1. 1

    Joins

    ~15 min · 2 lessons

    Combine customers, orders and products into one answer.

    JOINLEFT JOINUNIONself join
  2. 2

    Subqueries & CTEs

    ~18 min · 2 lessons

    Break a hard question into small named steps.

    IN (…)EXISTSWITHRECURSIVE
  3. 3

    Dates & text

    ~25 min · 3 lessons

    Group sales by month, clean up names and label rows with rules.

    strftimeSUBSTRLOWERCASE WHEN

Milestone 3 · Interview-ready

Advanced

The techniques that show up in real interviews and real pipelines.

  1. 1

    Window functions

    ~22 min · 2 lessons

    Rank products, compute running totals and compare to the previous row.

    OVERPARTITION BYRANKLAG
  2. 2

    Analytics patterns

    ~31 min · 3 lessons

    Build the retention, growth and top-N reports analysts ship weekly.

    cohortsMoM growthtop-N
  3. 3

    Query performance

    ~17 min · 2 lessons

    Explain why a query is slow and make it fast.

    INDEXEXPLAINrewrites