Skip to content

SQL practice

SQL practice: 10 exercises, a playground and lessons, all free

Every SQL practice question here runs against a real SQLite database inside your own browser: you write the query, press Run, and the result is checked against what the exercise asked for. Start with SELECT and WHERE, work up to JOINs, GROUP BY and window functions, and use the playground whenever you want to try a query of your own.

checked exercises
10
graded problems
0
lessons
8
cheat sheet
1

SQL practice exercises

How the path works →

In order, each one introducing a single new idea. Press Run to check your answer; hints open one at a time.

  1. Your First SELECTSELECT names the columns you want back
  2. Pick the Right RowsAND narrows a filter while OR widens it
  3. The Dearest ThreeORDER BY is what makes LIMIT mean anything
  4. Tools per ShelfGROUP BY splits an aggregate into one answer per group, and HAVING filters those groups
  5. Name the ToolJOIN ... ON pairs rows from two tables by a matching column
  6. Nobody Left OutLEFT JOIN keeps unmatched rows, and count(*) then miscounts them
  7. Above the AverageA CTE names an intermediate result so a later step can use it
  8. The Missing WHEREUPDATE without WHERE changes every row, and a transaction is what makes a mistake undoable
  9. The Running TotalORDER BY inside OVER turns an aggregate into a running one
  10. Two per ShelfPARTITION BY restarts a window function's numbering for each group

SQL lessons behind the practice

All lessons →

SQL cheat sheet

Everyday syntax on one page, for when you remember the idea but not the spelling.

SQL interview questions

Original questions with full model answers, for when the practice is going somewhere specific.

Questions people ask

Is this SQL practice free?
Yes. All 10 SQL exercises, the 8 lessons, the cheat sheet and the SQL playground are free, with no account and no email required.
Do I need to install a database to practise SQL here?
No. The queries run against SQLite compiled to WebAssembly, loaded into your browser tab. Nothing is installed on your computer and nothing you type is sent to a server.
Which SQL dialect do the exercises use?
SQLite. The core of SQL — SELECT, WHERE, ORDER BY, JOIN, GROUP BY, HAVING, subqueries, CTEs and window functions — is the same across SQLite, PostgreSQL and MySQL, so what you practise here carries over; only vendor-specific functions differ.
Do the SQL practice questions come with answers?
Each exercise has hints that open one at a time and a full solution query that unlocks once you have run your own attempt at least once, along with an explanation of the idea it teaches.

Practise another language

The same kind of practice hub exists for Python, JavaScript, TypeScript, Java, C++, C, C#, Go, PHP, Ruby, R and Bash & the Shell.