I Built a SQL Detective Game. Here's What 3,000 Players Taught Me About Learning SQL
Most people learning SQL hit the same problem I did: the courses are either textbook-heavy or video-heavy. You watch someone type SELECT * FROM customers, nod along, and forget it by Thursday.
The one thing that ever made SQL stick for me was SQL Murder Mystery: a crime, a database full of evidence, and the only way to the culprit is a query. So I set out to build that idea into a whole course: a SQL detective game with a real course behind it.
It's called QueryCase, and it launched in June. Five months and 3,000-odd players later, I have something most SQL courses don't share: data on exactly where learners get stuck. Here's what it shows.
What a SQL detective game actually is
Each lesson is a case. You get a short briefing (a shop has been robbed, a speed camera reads 412 mph, a payroll looks padded), a database full of evidence, and a question only a query can answer.
You write real SQL, and it's checked against the result it should produce, so any correct query passes, not just the one I wrote.
There are 54 cases across five ranks, from Recruit to Chief Detective. They start at SELECT and WHERE, then move through JOINs and GROUP BY to subqueries, CTEs and window functions. Each rank ends in an exam and a certificate.
Everything runs in your browser on DuckDB-WASM, so there's nothing to install, and you can solve the first case before making an account. The median player cracks it in 43 seconds.
The numbers so far
- 3,100+ people have signed up, across 122 countries
- 15,400+ SQL cases, drills and exams solved
- 530+ people have passed the free Rookie exam and earned the certificate
- An instructor at a US community college used it to teach SQL in a CompTIA Data+ prep lab, then came back with a second class
- The top detective is on 20,527 XP
And who's playing: about half of new players say they've never written code like this before. Most are learning for a reason. About half want a new job in data, and a third want to get better at the one they have.
Where 3,000 players get stuck
Every query a player runs is checked, so I can see which steps cause the most wrong answers, and why. Three steps stand out, each with thousands of attempts.
1. GROUP BY is the first real wall
The hardest step in the early game asks you to find the hotspot: count incidents by location and find where they cluster. It's the first time players combine COUNT(*) with GROUP BY.
Of roughly 3,700 runs on that step, about 83% came back wrong. Two out of three of those wrong runs never ran at all. They were SQL errors, not wrong answers.
The two usual causes:
- The clauses are in the wrong order. SQL is strict about it:
SELECT,FROM,WHERE,GROUP BY,HAVING,ORDER BY,LIMIT. - A column in
SELECTisn't in theGROUP BY. Every column inSELECThas to be either inside an aggregate (COUNT,SUM,AVG...) or listed inGROUP BY.
If GROUP BY is where you are right now, those two rules will fix most of your errors.
2. Writing a full query from scratch
Earlier on, a case asks for the first complete query a player writes alone: three named columns, sorted highest value first, top five only. Every piece has been taught; the step is putting them together.
Of about 2,700 runs, 76% came back wrong, and 61% of those were errors again. Mostly ORDER BY and LIMIT in the wrong place, or a stray LIMIT from an earlier step.
Knowing each clause isn't the same as knowing the order they go in, and that gap is bigger than most courses assume.
3. A query that runs isn't a query that's right
The third hardest step uses NOT IN to find vehicles that aren't on a list of flagged plates. Here the pattern flips. Of about 3,200 runs, 70% were wrong, but most of those ran perfectly and returned the wrong rows.
One common cause: typing a plate in lower case when the data is in upper case, which SQL treats as a different value.
That's the most important lesson in the data, and the one beginners learn last. SQL rarely tells you you're wrong. It hands back a confident, tidy table of the wrong answer. Checking your result against the question you were asked is a skill in itself.
What the data changed
Three things I'd tell anyone teaching SQL, or learning it alone:
- Teach the order of the clauses as a rule, not something you pick up along the way. Most failed runs on the hardest steps weren't misunderstandings of the idea. They were queries that never ran. A wall chart of
SELECT,FROM,WHERE,GROUP BY,HAVING,ORDER BY,LIMITwould prevent a lot of frustration. - Make every result answer a question. A detective case gives every query a reason: you're not filtering rows for practice, you're ruling out a suspect. That's also what makes the third lesson stick. When the result names the wrong car, you notice.
- Be honest about drop-off. About 2,700 people have solved at least one SQL case, and about one in five has gone on to pass the Rookie exam. That's better than most self-paced courses, but it means the first rank has to earn people's time, which is why it's free and why the first case needs no account.
Beyond SQL
People kept asking for the same approach for other data tools, so QueryCase has grown:
- Excel: 57 cases on a spreadsheet that runs in your browser, from
IFandXLOOKUPtoSUMIFSand pivot tables, with no Excel licence needed. - Python: real Python in the browser. A free Foundations course, then pandas and statistics, with machine learning and automation coming next.
Every track works the same way: a case, a dataset, and a question only your code can answer.
Quick answers
What is a SQL detective game? A way to learn SQL where each lesson is a mystery. You query a database of evidence to solve it, instead of working through abstract exercises.
Are there games like SQL Murder Mystery for beginners? Yes. QueryCase starts from your very first SELECT, and its first rank is free, with an exam and a certificate at the end.
Do I need to install anything? No. QueryCase runs in your browser, and you can try the first case without an account.
Try the SQL detective game
If you're learning SQL right now, or you've stalled on GROUP BY, the first case takes under a minute: querycase.com/sql.
I'd love to hear where you got stuck learning SQL, and whether the story helped or got in the way.
Comments
No comments yet. Start the discussion.