Learn SQL · Practice notebook Interactive DB lab
SQL practice, one query at a time
Write real SQL on a library of famous books, from Sherlock Holmes to Harry Potter, right in your browser. Every answer is checked instantly, with a plain-English explanation when it's wrong. Know Excel already? Each lesson shows the formula that does the same job.
- 27 lessons ready
- Runs on SQLite in your browser
- Nothing leaves your device
STEP 01 3 of 3 ready
Start here: SELECT
Ask a table for the columns you want.
STEP 02 5 of 5 ready
Picking rows
Keep only the rows you need with WHERE.
STEP 03 2 of 2 ready
Sorting
Put rows in order and keep the top few.
STEP 04 3 of 3 ready
Totals and groups
Count, add up and average, per group.
STEP 05 4 of 4 ready
Joining tables
Bring two tables together on a shared column.
STEP 06 3 of 3 ready
CASE and functions
Labels, text and dates.
STEP 07 2 of 2 ready
Queries inside queries
Use one result inside another.
STEP 08 3 of 3 ready
Window functions
Rankings and running totals, a favourite in interviews.
STEP 09 2 of 2 ready
Changing data
Add, change and remove rows.
Know someone fighting with a spreadsheet? Send them this page.