The tools nobody teaches

Pro lesson All levels

Someone else's SQL

Find your way around a model you did not write: read it in the right order, test each step on its own, find the join that duplicates rows, and prove your fix.

15 min7 hands-on steps

In this lesson you will

  • Read a long query in the right order
  • Run one step of a query on its own
  • Find the step that breaks the grain, fix it, and prove the fix

Words you'll meet

Model
A saved query that turns raw tables into something people report on.
CTE
A named step inside a query: WITH name AS (query). Later steps use it like a table.
Grain
What one row stands for. Every step of a model has one.
Reconciliation
Checking that a total in your model matches the same total in the source.

The steps

Each step teaches one idea, then has you try it hands-on in your browser, and checks your work.

  1. 1Start at the end
  2. 2Reproduce the complaint
  3. 3Run one step on its own
  4. 4Test the grain of each step
  5. 5Why order 3?
  6. 6Fix the step, not the symptom
  7. 7Challenge

This lesson is part of LearnDE Pro

$12 a month or $100 a year: every lesson, spaced-repetition flashcards, and Learn by teaching. Refund on request within 14 days.