SQL in the Age of AI

Course

Ask the Data

A hands-on 15-lesson course, taught by your own AI coding agent: write SQL by hand, then audit the SQL the agent writes for you.

Most SQL courses teach you to write queries. This one teaches you to trust them.

  • An agent will write most of your SQL now, 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: an error stops, a wrong number ships.
  • You learn it in two halves: first write SQL by hand, because you cannot audit what you cannot read, then bring in an agent and learn the loop that makes its answers safe to use.
  • Your coding agent teaches the whole course, step by step. These pages are a companion - read along, or use them for reference.

How it works

The course is taught by your agent, not by these pages. Four steps to start:

1. Install a coding agent or AI IDE. Claude Code, Codex, or Cursor - any one works.

2. Copy this prompt and paste it to your agent. It sets up your learning environment: installs what it needs, builds a small local practice database, and hands you the controls.

AI Prompt

You are going to set up and then teach me an interactive SQL course. Do this in order, and show me each command before you run it:

  1. Check that Git and Bruin are installed (git --version, bruin version). If Bruin is missing, install it with curl -LsSf https://getbruin.com/install/cli | sh, then check the version again.
  2. Run bruin init academy-sql-beginner in this folder.
  3. Generate the sample data with bruin run academy-sql-beginner/pipeline, then confirm orders has 1,200 rows and order_items has 2,880.
  4. Read academy-sql-beginner/AGENTS.md and academy-sql-beginner/course/README.md so you know how to run the course.
  5. Greet me, show me the 15-lesson syllabus, and tell me to say "next lesson" to begin and "review my work" whenever I finish a task.

Do not teach lesson one yet - just get set up and hand me the controls. If any command fails, stop and show me the error instead of trying something else.

3. Learn the concepts, then say next lesson. The agent teaches each lesson and asks a few quiz questions to check you followed. When you have it, tell it next lesson to move on.

4. Do the task, then say review my work. Most lessons set a hands-on task, usually a query to write yourself. Do it by hand, then ask the agent to review it - it runs your work, checks it against a rubric, and tells you what to fix.

That loop is the whole point: the agent does the work, and you check it.

It is terminal-first on purpose. An agent works with a warehouse by writing SQL and running commands, so learning in the same place is what lets you read and direct it. You will use Bruin and DuckDB, but the ideas transfer to dbt, Dataform, or any SQL framework.

Before you start

  • An AI coding agent: Claude Code, Cursor, or Codex. One setup prompt has it install everything else.
  • A terminal and a code editor. No prior SQL, no database, and no cloud account required.

15 steps

Course outline

Start course

Set up the workspace

Install the tools, let an agent build the project, and learn what a warehouse actually is.

  1. 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.
  2. 2What you can and cannot delegateTell a loud failure from a silent one, and learn why you audit SQL you did not write.
  3. 3Start the course with one promptInstall a coding agent, paste one prompt, and let it set up the project and hand you the controls.
  4. 4Meet the warehouseLearn what tables, rows, grain, and a connection are, then look around the data.

Write your own SQL

Type every query yourself. This is the part you cannot skip.

  1. 5Ask one table a questionWrite SELECT, WHERE, ORDER BY, and LIMIT by hand, and catch your first silent failure.
  2. 6Count, sum, and groupAggregate with COUNT, SUM, and AVG, group by a column, and see how NULLs skew each one.
  3. 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.
  4. 8Name your steps with CTEsBreak a query into named steps with WITH, and learn the order SQL actually runs in.

Bring in the agent

Ask in plain English, read what comes back, and interrogate it.

  1. 9Ask the agent for a queryTurn a plain-English question into a well-formed request, and always read the SQL first.
  2. 10Audit what it wroteRun a seven-point checklist over an agent's query, and verify the number a second way.
  3. 11Interrogate the logicPush back on an agent's query with four moves, and reconcile every answer against anchors.
  4. 12Fix the context, not the promptWrite a correction into the repository so it holds for every future conversation.

Make it stick

Save your work, then prove you can catch a wrong answer.

  1. 13Save a query as an assetTurn an audited query into a Bruin asset with a header, dependencies, and a description.
  2. 14Capstone: find the six wrong queriesTen queries all run without error. Exactly six are wrong. Find them, name the fault, and fix each.
  3. 15Recap and next stepsThe habits you built, and where to take them next.

Frequently asked questions

  • How is the course taught?
    By your own coding agent. You paste one setup prompt, then drive with two commands: say 'next lesson' and the agent teaches it and sets a task; do the task by hand and say 'review my work' and it checks your work against a rubric. These pages are a companion you can read alongside.
  • 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 writes one for you. 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 148 minutes of reading across 15 lessons, including the capstone. Each lesson is 5 to 25 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.

Get help & contribute

Sign up to our newsletter

Practical updates on open-source data pipelines, AI analysts, governance, and what we are shipping at Bruin.

The signup form is hosted by Brevo. Allow marketing cookies to load it.