
Data and engineering
SQL from scratch
Real SQL, running in your browser, on the database of a fictional shop.
- units
- 9
- lessons
- 26
- minutes
- 151
- exercises
- 156
The first unit is free, no credit card required. The other 8 unlock when you buy the course or go Pro. Single course: $12.99, one-time payment.
What's in the course.
From SELECT to window functions, with queries that really run.
9 units, 26 lessons, and about 151 minutes of practice, a few minutes at a time.
Read data from a table: pick columns with SELECT and filter rows with WHERE.
In this unit, you'll learn to
- Pick columns with SELECT
- Read the right table with FROM
- Filter rows with WHERE
Lessons
- SELECT and FROM, unlocked6 exercises · 5 min
- Filtering with WHERE, unlocked6 exercises · 6 min
Sort results, take the first few and combine conditions with AND, OR, IN, LIKE and NULL.
In this unit, you'll learn to
- Sort with ORDER BY and cut with LIMIT
- Combine conditions with AND, OR and IN
- Match patterns with LIKE and handle NULL
Lessons
- ORDER BY and LIMIT, locked6 exercises · 6 min
- AND, OR, IN, LIKE and NULL, locked6 exercises · 6 min
- Filters that mislead, locked6 exercises · 5 min
Summarise many rows into numbers: count, sum, average and group.
In this unit, you'll learn to
- Count and add up with COUNT, SUM and AVG
- Group results with GROUP BY
- Filter groups with HAVING
Lessons
- COUNT, SUM and AVG, locked6 exercises · 5 min
- GROUP BY and HAVING, locked6 exercises · 6 min
- Counts that don't match, locked6 exercises · 5 min
Combine tables: orders with customers, items with products, and find who was left out.
In this unit, you'll learn to
- Combine tables with INNER JOIN
- Keep unmatched rows with LEFT JOIN
- Find orphan records with IS NULL
Lessons
- INNER JOIN, locked6 exercises · 6 min
- LEFT JOIN, locked6 exercises · 6 min
- Joins that duplicate rows, locked6 exercises · 6 min
Queries inside queries, and WITH to break big problems into named steps.
In this unit, you'll learn to
- Use subqueries in the WHERE
- Test for existence with EXISTS
- Organise the logic in CTEs with WITH
Lessons
- Subqueries, locked6 exercises · 6 min
- CTEs with WITH, locked6 exercises · 6 min
- Steps, recursion and NOT IN, locked6 exercises · 6 min
Rankings, numbering and running totals without losing the detail of each row.
In this unit, you'll learn to
- Number and rank with ROW_NUMBER and RANK
- Split groups with PARTITION BY
- Calculate running totals and compare with the previous row
Lessons
- ROW_NUMBER and RANK, locked6 exercises · 6 min
- Running totals and LAG, locked6 exercises · 6 min
- Frames, ties and % of total, locked6 exercises · 6 min
CASE, text, dates, UNION and quality tests: get the data ready before you add anything up.
In this unit, you'll learn to
- Build bands and boards with CASE
- Handle text, dates and empty values
- Test for duplicates, nulls, orphans and out-of-range values
Lessons
- CASE, COALESCE and NULLIF, locked6 exercises · 5 min
- Text and dates in practice, locked6 exercises · 6 min
- UNION, EXCEPT and data quality, locked6 exercises · 6 min
Repeat buyers, RFM and cohorts, how the database runs a query and what changes between databases.
In this unit, you'll learn to
- Measure repeat buyers, RFM and cohorts with CTEs
- Read a query plan and make use of an index
- Translate queries between SQLite, PostgreSQL, SQL Server and Databricks
Lessons
- Repeat buyers, RFM and cohorts, locked6 exercises · 6 min
- How the database runs it, locked6 exercises · 6 min
- Dialects and interviews, locked6 exercises · 6 min
Farol Store's revenue fell in the second quarter. From the board's question to a final query that checks out.
In this unit, you'll learn to
- Turn a vague question into metric, period and grain
- Find where revenue fell by product and by customer
- Build, check and present the final query
Lessons
- From question to scope, locked6 exercises · 6 min
- Where revenue fell, locked6 exercises · 6 min
- The query for the board, locked6 exercises · 6 min
Try it for real.
Ready to write some queries? Real exercises from this course, solved step by step, exactly as they appear in the app.
156 exercises across 6 types in this course
- Write SQL82
- Pick the best answer35
- Fill in the code18
- Match14
- Put it in order6
- Tap the chart1
Write SQL. You write the query, run it, and see the result instantly.
Show the name and price of every product.
SELECT name, price FROM products;
Correct. Two columns, one table, no filter: all 8 rows of products appear.
Fill in the code. You pick the right piece from the word bank and see why the others don't fit.
Fill in the blanks to list the name and city of every customer.
name, city customers;
Correct. Every query starts with SELECT (what to show) and FROM (where it comes from).
Pick the best answer. A real workday situation and options that all sound right.
Which command picks the columns you want to see?
- ASELECT
- BFROM
- CWHERE
- DORDER BY
Correct. SELECT defines the columns in the result. FROM says which table they come from.
Practice exams for this course
This course prepares you for these exams. Try free questions before you practice in the app.





