SQL Dojo

SQL

The SQL language, from the first SELECT to recursive queries. One belt per level.

  • 310+ exercises
  • 7 belts
  • white belt free, no account needed
Start the white belt →
  1. White belt

    28 steps Free

    Answer a question about one table: select, filter, sort, count, per group and per month.

    • The query
    • Filtering
    • Sorting and limiting
    • Conditions
    • Counting
    • Capstone
  2. Yellow belt

    30 steps

    Work with real values, still on one table: types, NULL, text and numbers, regular expressions, dates, time zones, dirty data; then change rows and create tables.

    • Types
    • NULL in depth
    • Text, numbers and patterns
    • Dates and time zones
    • Dirty data
    • Changing rows
    • Creating tables
    • Capstone
  3. Orange belt

    30 steps

    Combine tables without losing or doubling rows: joins (a calendar spine too), subqueries (correlated too), CTEs, set operations.

    • Joins
    • Subqueries
    • CTEs
    • Set operations
    • Capstone
  4. Green belt

    30 steps

    Compare rows: window functions, ranking, offsets, running aggregates, frames; then load a table from a query, MERGE included.

    • The window
    • Ranking
    • Offsets
    • Running aggregates
    • Window frames
    • Aggregates for analysis
    • Loading from queries
    • Capstone
  5. Blue belt

    29 steps

    Reshape data for reports: more joins and subqueries, subtotals, pivot, calendars, lists and JSON.

    • More joins
    • More subqueries
    • Subtotals
    • Pivot
    • Calendars and series
    • Lists and structs
    • JSON
    • Capstone
  6. Brown belt

    24 steps

    Handle the hard cases: real-world values (time zones, invisible characters, regular expressions), conditional MERGE, lateral and as-of joins, the rest of window functions (ranges, IGNORE NULLS, EXCLUDE).

    • Real-world values
    • Merge
    • Lateral and as-of joins
    • The rest of windows
    • Capstone
  7. Black belt

    22 steps

    Solve open problems and review other people's SQL: recursion, gaps, islands and sessions, reviews of whole queries.

    • Recursion
    • Gaps, islands and sessions
    • Reviews
    • Capstone