Course
Ask the Data
A practical 15-step course on writing SQL by hand, then auditing the SQL an AI agent writes for you.
Most SQL courses teach you to write queries. This one teaches you to trust them. An analyst starting today will have an agent write most of their SQL, so the scarce skill is no longer typing it. It is reading, auditing, and directing SQL that something else wrote.
A wrong number that looks right is worse than an error, because an error stops and a wrong number ships. This course spends its first half making you fluent enough to read SQL, and its second half turning that fluency into a repeatable audit.
What you'll build
You will work against a small generated retail warehouse: 1,200 orders, 2,880 order lines, 500 customers, and three years of history from 2023 to 2025. One command builds it locally, with no download and no account.
You write SQL by hand first, because you cannot audit what you cannot read. Then you bring in an agent, ask it the course's spine question, and learn the loop that makes its answers safe to use.
generated sample data
-> your own SQL, written by hand
-> the same question asked of an agent
-> read, interrogate, verify
-> a saved, documented asset
By the end you can set up a real data project with an agent's help, write basic SQL yourself, ask an agent for a query in plain English, and tell whether its answer is right.
How it works
Every lesson starts with a decision, then shows one way to implement it with Bruin and DuckDB. The ideas transfer to dbt, Dataform, SQLMesh, or an in-house framework. Bruin is the environment, not the subject.
The course is terminal-first. You run queries with bruin query and read the output, because a reader who freezes at a real prompt has not learned to audit. The data is deliberately imperfect: NULLs where they matter, a duplicated key, orphan foreign keys. Finding them is the exercise.
The manual instructions remain the source of truth. When you use an agent, read its SQL before it runs, inspect the diff, and check the output before moving on. You do not need a cloud account, a warehouse, a credit card, or any prior SQL. You do not need to know Git either - one lesson has an agent set it up while you watch.
Where the repository maps to the course
The template is self-contained, so a student who starts in the repository can see which lesson each file belongs to:
| Step | Lesson | Repository file |
|---|---|---|
| 1 | SQL, databases, and agents in plain words | README.md |
| 2 | What you can and cannot delegate | docs/failure-modes.md |
| 3 | Set up the project with one prompt | README.md, AGENTS.md |
| 4 | Meet the warehouse | docs/schema.md |
| 5 | Ask one table a question | queries/01-first-look.sql |
| 6 | Count, sum, and group | queries/02-aggregates.sql |
| 7 | Join two tables without breaking the number | queries/03-joins.sql |
| 8 | Name your steps with CTEs | queries/04-cte.sql |
| 9 | Ask the agent for a query | AGENTS.md, queries/ |
| 10 | Audit what it wrote | queries/audit-template.md |
| 11 | Interrogate the logic | queries/anchors.md |
| 12 | Fix the context, not the prompt | AGENTS.md, pipeline/assets/ |
| 13 | Save a query as an asset | docs/writing-an-asset.md |
| 14 | Capstone: find the six wrong queries | queries/audit-lab/ |
| 15 | Recap and next steps | README.md |
Before you start
- A terminal you are willing to type into. No prior SQL required.
- An AI coding tool: Claude Code, Cursor, or Codex. The setup lesson shows how to install one.
15 steps
Course outline
Set up the workspace
Install the tools, let an agent build the project, and learn what a warehouse actually is.
- 1SQL, databases, and agents in plain wordsWhat a database, a table, a query, a warehouse, and an AI coding agent actually are - defined before anything is assumed.6 min
- 2What you can and cannot delegateTell a loud failure from a silent one, and learn why you audit SQL you did not write.6 min
- 3Set up the project with one promptOpen a terminal, install Git, an AI coding tool, and Bruin, then generate the sample data locally.15 min
- 4Meet the warehouseLearn what tables, rows, grain, and a connection are, then look around the data.8 min
Write your own SQL
Type every query yourself. This is the part you cannot skip.
- 5Ask one table a questionWrite SELECT, WHERE, ORDER BY, and LIMIT by hand, and catch your first silent failure.10 min
- 6Count, sum, and groupAggregate with COUNT, SUM, and AVG, group by a column, and see how NULLs skew each one.10 min
- 7Join two tables without breaking the numberJoin on a key, then catch fan-out and a LEFT JOIN that quietly turns into an INNER JOIN.12 min
- 8Name your steps with CTEsBreak a query into named steps with WITH, and learn the order SQL actually runs in.8 min
Bring in the agent
Ask in plain English, read what comes back, and interrogate it.
- 9Ask the agent for a queryTurn a plain-English question into a well-formed request, and always read the SQL first.10 min
- 10Audit what it wroteRun a seven-point checklist over an agent's query, and verify the number a second way.12 min
- 11Interrogate the logicPush back on an agent's query with four moves, and reconcile every answer against anchors.10 min
- 12Fix the context, not the promptWrite a correction into the repository so it holds for every future conversation.8 min
Make it stick
Save your work, then prove you can catch a wrong answer.
- 13Save a query as an assetTurn an audited query into a Bruin asset with a header, dependencies, and a description.8 min
- 14Capstone: find the six wrong queriesTen queries all run without error. Exactly six are wrong. Find them, name the fault, and fix each.25 min
- 15Recap and next stepsThe habits you built, and where to take them next.5 min
Frequently asked questions
Do I need to know SQL to take this course?
No. The course starts from SELECT and has you writing queries by hand before any agent is involved. Section 2 covers filtering, aggregating, grouping, and joins from scratch.Do I need a database or a cloud account?
No. The template generates a small retail dataset on your machine in about a tenth of a second. There is no cloud account, no credit card, and no credentials. An optional MotherDuck path exists if you want a cloud warehouse.Which AI tool do I need?
Claude Code, Cursor, or Codex. The course is written against the Bruin CLI, so anything that can run a terminal command works.Is the course free?
Yes. All 15 lessons are open, and nothing in the lesson content is gated. Registration is also free and adds a community channel, office hours, and a certificate.Does it work on Windows?
Yes, through Git Bash or WSL. Git Bash comes with the Git for Windows installer, and the setup lesson walks through it. macOS and Linux work out of the box.How long does it take?
About 153 minutes of reading across 15 lessons, including the capstone. Each lesson is 5 to 15 minutes and a section is roughly 25 to 45 minutes, so you can complete one section per sitting. Practice time on top of that runs from hours to days.
Additional resources
Get help & contribute