HACKER Q&A
📣 novoreorx

Are there any websites for SQL puzzle games?


As a Python programmer, I often use Django or SQLAlchemy ORM and as a consequence, my proficiency in raw SQL remains at a basic level. However, I am keen on improving my raw SQL skills, given it's sometimes superior to ORM, and because I find SQL and relational algebra surprisingly fun to think about.

Does anyone know of websites that provide SQL puzzle games that allow users to solve problems by writing SQL and validating them? I believe this would be an engaging way to enhance my SQL skills. Your suggestions are appreciated!


  👤 jiehong Accepted Answer ✓
Maybe less fun than others, but actually not so bad: leetcode [0]

Otherwise, in the same vein as the SQL murder mystery, you can try the Hanukkah of Data [1].

[0]: https://leetcode.com/problem-list/leetcode-curated-sql-70/

[1]: https://hanukkah.bluebird.sh


👤 shouldnt_be
I often use https://pgexercises.com/ to refresh my knowledge

👤 NortySpock
Others have given you excellent suggestions; I will simply offer an addition -- a side quest, if you will:

Remember that the local single-user databases SQLite and DuckDB exist, and that you can use them to wrangle data without even having to set up a separate server. You just create a database file on your machine and go from there.


👤 arono
I’ve had fun going through SQL Murder Mystery (https://mystery.knightlab.com/)

I even use it for hiring exercises.


👤 newprint
www.sql-ex.ru + the book on that site are by far the best SQL exercises I have seen. PS. I know you asking about just RAW SQL, but I highly suggest you get into understanding how particular DBMS works in depth, what plans it builds, what concurrency mechanisms it uses. Writing raw SQL will get you only so far, making those queries actually production ready is completely different ballgame and for that, you don't need to be super proficient in SQL.

👤 Leftium
SQL Police Department – Learn SQL while solving crimes:

- https://hw.leftium.com/#/item/23066776

Lost at SQL: The SQL learning game:

- https://hw.leftium.com/#/item/35665142

There are even more games in the comments.


👤 leifhka
Not quite puzzles, but since someone else mentioned Schemaverse, I have made a similar but Elite inspired SQL-game called Datastar [1]. It features a simulated economy with traders and miners, and the goal is to make as much money as possible. Everything is done via SQL (or other PostgreSQL features), and the player need to make and manage a database of information about the planets and their economies.

I teach uni. couses on databases and made the game for my student to give them a more self-driven way to learn SQL.

[1] https://gitlab.com/leifhka/datastar


👤 liamN
Maybe this is more begginner than youre looking for, but I saw this one ("Lost at SQL") here on HN last year. https://lost-at-sql.therobinlord.com/

👤 geshan
Not a game but a great way to learn SQL is https://sqlbolt.com

👤 speedgoose
A few of them exist. I played a bit on the SQL section of HackerRank in the past: https://www.hackerrank.com/domains/sql

👤 gabrielsroka

👤 evilotto
There used to be a multiplayer space game called Schemaverse that was played by writing sql, but it seems to have gone away.

https://schemaverse.com/


👤 BazookaMusic
https://detective.kusto.io/

It's not SQL directly (it's the Kusto query language) which is more geared towards reading data and analytics.

I'm suggesting it however because the queries in it are also basically relational algebra (aka much of the knowledge is transferable to SQL - minus some special features like anomaly analysis), they give decently sized datasets with billions of rows and the challenges themselves were fun.


👤 PascLeRasc
Select Star SQL is pretty interesting, but short - https://selectstarsql.com/beazley.html

👤 roland35
This SQL murder mystery is fun and helpful! https://mystery.knightlab.com/

👤 uncharted9
Thanks everyone who have commented all these sites. I wanted to brush up SQL for interviews and these will help a lot.

👤 laowantong
At beginner level, there is SQL Island https://sql-island.informatik.uni-kl.de, with versions in German, English and French.


👤 yurpree43
Codesignal has a fun Database “Arcade” https://app.codesignal.com/arcade/db

👤 Cheezmeister
Thanks for asking. Had a similar issue--no avenue to practice queries intentionally, outside of solving a real-world problem with all the confounding factors that entails.

Nice options ITT.



👤 jasonpeacock
A coworker used to solve Project Euler[1] problems using SQL while they waited for DB indexes to rebuild or tables to restore from backup in the middle of the night.

[1] https://projecteuler.net/


👤 fuzztester
UPDATE POSTS SET VOTE_COUNT = VOTE_COUNT + 1 WHERE POST_ID = CURRENT_POST_ID();

CREATE TABLE SQL_GAMES blah blah blah

INSERT INTO SQL_GAMES many invited users blah blah blah

SELECT * FROM SQL_GAMES WHERE users are having fun blah blah blah

PROFIT blah blah blah

ENJOY even more blah

-- TODO: drastically restructure above schema and SQL statements to make more sense blah blah blah

-- there's your game blah blah blah