SQL Block Game is a free SQL practice game that runs in your browser. Query cards fall from the top of the screen. Write the SQL that answers a card before it lands, and the card clears. A card that lands stays on the stack, and when the stack gets to the top, the run ends. Every query runs on a real PostgreSQL database in your browser tab. You do not need an account to play.
How do you play SQL Block Game?
Each run uses the same loop:
- A card falls into one of three lanes. The card tells you what to return, for example "Count of customers per state".
- You type the SQL and press Enter.
- A correct result clears the card and gives you points. A card that is high in the well gives more points, and so do clears in a row.
- A card that lands stays on the stack. You can still answer it, for fewer points.
- When a stack gets past the red line at the top, the run ends.
The level goes up after every 5 clears. At a higher level, the cards fall faster and come more often. Press Tab to move to a different card, and Esc to pause. On the pause screen you can end the run, and the game saves your score.
What SQL do you practice in SQL Block Game?
The game has four tiers and 72 cards. Pick one tier, or pick Escalate: the game starts at WHERE
and adds a new tier every 2 levels. All cards use the same two tables, customers and
orders. The schema stays on screen for the full run, so you do not have to remember the
column names.
| Tier | The cards ask you to | Cards | Free lesson |
|---|---|---|---|
| SELECT + WHERE | Select columns and filter rows. | 20 | WHERE |
| ORDER BY + LIMIT | Sort rows and keep the top rows. | 18 | ORDER BY, LIMIT |
| COUNT / SUM / AVG | Count, add up or average a column. | 18 | Aggregate functions |
| GROUP BY | Return one row for each group. | 16 | GROUP BY |
Fill the blank or full query: which SQL Block Game mode is for you?
Fill the blank prints the query and leaves one part empty. You type only that part, so the cards fall faster. Use it to learn where each clause goes.
Full query gives you the card and an empty editor. You type the whole query, so the cards fall slower. Use it when you can write the query from memory. In this mode, one query clears every card on screen that it answers.
Each mode and each tier has its own leaderboard, so the two modes never compete.
What does one SQL Block Game card look like?
This is a real card from the GROUP BY tier, with the rows that a correct answer returns.
Count of customers per stateReturn: state, count
Fill the blank: type the missing part
SELECT state, COUNT(*) FROM customers GROUP BY ___ Full query: type all of it
SELECT state, COUNT(*) FROM customers GROUP BY state | state | count |
|---|---|
| OH | 5 |
| TX | 3 |
| WA | 3 |
| OR | 1 |
The blank takes state.
How does SQL Block Game check your query?
The game runs your query on PostgreSQL, compiled to WebAssembly, in your browser tab. Then it compares your rows with the rows of a correct query. The text of your query does not matter, so any correct query clears the card.
- The order of your columns does not matter. The number of columns does.
- The order of your rows matters only when the card asks for a sort.
- Numbers match to 2 decimal places.
- A syntax error shows a message and costs nothing.
- A wrong result resets your streak and moves the card down a little.
- The game accepts only SELECT queries, and nothing you type changes the data.
How does the SQL Block Game leaderboard work?
Each mode and tier has a leaderboard for Today, This week and All time. Today starts again at 00:00 UTC. Each player shows one time, with their best run. To get on the board, make a free account and pick a name and a pixel character.
The server scores each run again from its record of clears before the run goes on the board. If you play as a guest first, the game keeps your runs, and they move into your account when you make one.
Who is SQL Block Game for?
It is for people who know the first SQL clauses and want to write them fast and without errors. It is also for people who prepare for a timed SQL screen in a job interview.
If you have never written SQL, start with Fill the blank at the WHERE tier. If you want a game that teaches new SQL with a story, play Station Zero, a SQL escape game.
SQL Block Game questions
Do I need an account to play SQL Block Game?
No. Open the page and press Play. You need a free account only to put your name on the leaderboard. Runs that you play as a guest are kept, and they move into your account when you make one.
Can I play SQL Block Game on my phone?
Not well. You type real SQL against a clock, so you need a keyboard. Use a laptop or a desktop computer.
How is SQL Block Game different from Station Zero?
Station Zero is a story that teaches new SQL, from your first SELECT to window functions and recursive CTEs. SQL Block Game teaches no new concept. It drills the basics at speed, up to GROUP BY on one table.
Does SQL Block Game save my score if I close the tab?
The game saves a run when it ends, also when you end it from the pause screen. A run that is still in progress when you close the tab is not saved.
Back to the game See every SQL game we ranked Browse the free SQL lessons