SQL on CSV
This is a SQL course you can finish in an afternoon, and every query in it runs for real. Not a code sample you copy somewhere else. Not a video of somebody else typing. You get an editor, a hundred rows of sales data already loaded, and a Run button, and when you press it a genuine SQL engine reads the CSV and answers you.
The engine is DuckDB compiled to WebAssembly. It
is the same engine that powers the rest of this site, which means nothing here is a teaching
subset that quietly falls over the first time you write a window function. Joins, CTEs,
QUALIFY, date functions:
all of it is available from lesson one, and all of it runs in your tab. Your queries are never
sent anywhere, because there is nowhere to send them.
The fifteen lessons
Work through them in order the first time. Each one assumes the one before it, and the exercises get harder in a straight line from "show me five rows" to "compute month over month growth with a window function". Every lesson takes five to twelve minutes.
- 01SELECT and LIMITYour first query, and why every one of them should start small.
- 02Choosing columns, and ASPick the columns you want, compute new ones, and name the result.
- 03Filtering with WHEREKeep the rows you care about, and learn what the equals sign really does.
- 04AND, OR, NOT, IN, BETWEEN, LIKECombining conditions without accidentally selecting the whole file.
- 05ORDER BY and top-NSorting, tie-breaking, and the two-line recipe for "the biggest ten".
- 06COUNT and DISTINCTCounting rows, counting values, and the difference that trips people up.
- 07SUM, AVG, MIN, MAXTurning a hundred rows into one number you can put in an email.
- 08GROUP BYOne number per region, per product, per anything.
- 09Two-column GROUP BY, and HAVINGA support-ticket file, grouped two ways, then filtered after the fact.
- 10Dates and monthsdate_trunc, EXTRACT, and getting a monthly trend out of daily rows.
- 11CASE expressions and bucketsInventing a category that is not in the file, then grouping by it.
- 12JOIN two filesThree CSVs in one query, and what an inner join quietly throws away.
- 13Window functionsRunning totals, ranks and LAG, without collapsing your rows.
- 14CTEs and subqueriesNaming an intermediate result so the next query can read like a sentence.
- 15Capstone: your own fileThree hard questions, then point the editor at a CSV from your own machine.
How the exercises are graded
By result, never by wording. When you press Check answer, your query runs and so does a reference query, and the two result sets are compared. Row order is ignored unless the question is about sorting, column order is ignored when the names line up, and numbers are compared with enough slack that a floating point sum in a different order still counts as the same total. If you find a shorter way to the right answer than the one I had in mind, the course agrees with you.
Two wrong attempts unlock a Show answer button. Use it. Reading a correct query and working out why it is correct is a real way to learn, and there is nobody here to impress.
What you need, and what you do not
You need a browser and about three hours. You do not need a database, a Docker container, a Python install, an account, or a credit card. The lesson data ships inside each page, so the only download is the engine itself, roughly four megabytes on the first query and cached after that.
You also do not need any prior SQL. Lesson 1 assumes you have opened a spreadsheet and nothing more. If you already write SQL and came here for the second half, skip ahead: lesson 12 on joins and lesson 13 on window functions stand on their own.
The data you will be querying
Five small CSV files, all fictional, all deterministic. A hundred rows of furniture sales covering the first half of 2025, ninety support tickets from a three-month stretch, and a matching set of orders, customers and products for the join lessons. Every file has a download link on the lesson that uses it, and each one is small enough to read end to end if you are the sort of person who likes to check the tool's arithmetic. In the sales file, revenue really is units times unit price, to the cent, on all one hundred rows.
Where this goes next
The point of the last lesson is to make the course disposable. Once your own file is in the editor and your own question is answered, you do not need the lessons any more, you need a bigger workbench. Two of them are on this site: SQL in the browser for a one-off query, and the full editor when the query is one step in a longer pipeline. Both run the same DuckDB you have been learning on, and both take files up to a gigabyte.
Questions people ask before starting
Does the SQL really run, or is it checked against a stored answer?
It really runs. Every lesson loads DuckDB into your tab and executes your query against the lesson CSV. Exercises are graded by comparing your result to the result of a reference query, so any query that produces the right answer passes, whatever wording you used.
Do I need to install anything or create an account?
No. There is no account, no email box and no install. The first query on a page downloads about four megabytes of engine from a CDN, and after that everything happens locally.
Does my data leave my computer?
No. The lesson files ship inside the page, and in the final lesson you can point the editor at a CSV of your own. That file is read by the browser and handed straight to DuckDB in the same tab. There is no upload endpoint to send it to.
Which SQL dialect does the course teach?
DuckDB, which follows PostgreSQL closely. Almost everything here works unchanged in Postgres, BigQuery, Snowflake and Redshift. Where a feature is a DuckDB convenience rather than standard SQL, the lesson says so on the spot rather than letting you find out later.
How long does the whole course take?
About three hours if you do every exercise, and a good deal less if you already write some SQL. Progress is saved in your browser, so stopping halfway costs nothing.
Start with five rows
Lesson 1 is one query long. Nothing to install, nothing to sign up for.
Open lesson 1