SQL Exercises With Answers
72 questions from 18 murder cases, sorted by skill and ranked by how real players did.
- 72 exercises from SELECT and WHERE up to window functions
- Every answer included, hidden until you click
- Real difficulty. Each exercise shows how many players got it right on their first query
- Free. No account and nothing to install
- No spoilers. The last question of each case names the killer, so it stays in the game
Pick a skill
Which SQL skill is hardest?
Share of solved exercises that players got right on their very first query, by skill.
From 4,262 solved questions in play sessions between October 24, 2026 and November 14, 2026. An exercise counts under every skill its answer uses. The final question of each case is not included.
The tables
Every exercise runs on the same small PostgreSQL database. Each row belongs to one case, so most queries start with WHERE case_id = ....
| Table | Columns | What it holds |
|---|---|---|
| suspect_info | id, case_id, name, role, relation, location, alibi_time | One row per suspect with their role, where they say they were and when |
| events | id, case_id, suspect_id, suspect_name, event_type, details, event_timestamp | What happened and when: sightings, testimony, the murder |
| suspect_reason | id, suspect_id, case_id, reason_type, summary, detail | Motives. Used in 6 of the 18 cases |
Start here: 5 warm-ups
The exercises players solve most often on the first try.
- Identify the Key Parties Involved (ORDER BY, DISTINCT and LIMIT, 90% first try)
- Meet the suspects (ORDER BY, DISTINCT and LIMIT, 89% first try)
- Meet the cast (ORDER BY, DISTINCT and LIMIT, 88% first try)
- Who was paid to stage the fake hold-up? (LIKE, BETWEEN and IN, 85% first try)
- Who stood to gain from the third victim's death? (LIKE, BETWEEN and IN, 82% first try)
The 10 hardest exercises
Ranked by the share of players who got them right on the first query. Most of them look simple. That is the trap.
- What are each suspect's alibi details? (JOINs, 11% first try, 75 players)
- Which "Sheppard" family members were in the Study? (LIKE, BETWEEN and IN, 15% first try, 178 players)
- How many suspects claimed each alibi location between 4:45 and 5:15 AM (GROUP BY, COUNT and HAVING, 16% first try, 115 players)
- Who was in the Drawing Room or the Garden? (LIKE, BETWEEN and IN, 19% first try, 195 players)
- Who last saw Roger Ackroyd alive? (SELECT and WHERE, 19% first try, 164 players)
- Who never saw the victim alive? (JOINs, 19% first try, 59 players)
- Who Was in Compartment 4? (LIKE, BETWEEN and IN, 21% first try, 384 players)
- Identify the Passengers (SELECT and WHERE, 30% first try, 505 players)
- Who was at the vicarage? (LIKE, BETWEEN and IN, 34% first try, 44 players)
- When and where was everyone? (SELECT and WHERE, 44% first try, 435 players)
How to use these exercises
- Pick a skill above and read the exercise
- Write your query before you open the hint or the answer
- Click the button under the exercise to run your query in the case it comes from
- The game checks your result rows, not your query text, so any correct query passes
Questions people ask
Are these SQL exercises free?
Yes. All 72 exercises, all the answers and all 18 cases are free. There is no account.
Which SQL dialect do they use?
PostgreSQL. Almost every answer also works in MySQL, SQL Server and SQLite. The few that don't use ILIKE, which is PostgreSQL's case-insensitive LIKE.
Where do the difficulty numbers come from?
From players. Every exercise is a question in the game. We count how many play sessions solved it on the first query. An exercise needs at least 20 solves before we show a number.
I'm a complete beginner. Where do I start?
Start with SELECT and WHERE or open Case 1 and let the story walk you through it.
Keep going: How the game works | What you'll learn | SQL explained