Home Cases Blog About

SQL Exercises With Answers

72 questions from 18 murder cases, sorted by skill and ranked by how real players did.

72exercises with answers
8SQL skills
18cases to run them in
44%solved on the first try

Pick a skill

SELECT and WHERE Pick columns and filter rows 7 exercises · 48% solved first try ORDER BY, DISTINCT and LIMIT Sort results, remove duplicates and take the top rows 17 exercises · 72% solved first try LIKE, BETWEEN and IN Match text patterns, ranges and lists 27 exercises · 34% solved first try GROUP BY, COUNT and HAVING Count and total rows by group, then filter the groups 10 exercises · 18% solved first try CASE WHEN Label rows with your own categories 3 exercises · 31% solved first try JOINs Combine rows from two or more tables 17 exercises · 24% solved first try Subqueries and CTEs Use one query inside another 5 exercises · 40% solved first try Window functions Rank rows and compare each row with the one before it 4 exercises · 35% solved first try

Which SQL skill is hardest?

Share of solved exercises that players got right on their very first query, by skill.

SELECT and WHERE 48%
ORDER BY, DISTINCT and LIMIT 72%
LIKE, BETWEEN and IN 34%
GROUP BY, COUNT and HAVING 18%
CASE WHEN 31%
JOINs 24%
Subqueries and CTEs 40%
Window functions 35%

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 = ....

TableColumnsWhat it holds
suspect_infoid, case_id, name, role, relation, location, alibi_timeOne row per suspect with their role, where they say they were and when
eventsid, case_id, suspect_id, suspect_name, event_type, details, event_timestampWhat happened and when: sightings, testimony, the murder
suspect_reasonid, suspect_id, case_id, reason_type, summary, detailMotives. Used in 6 of the 18 cases

Start here: 5 warm-ups

The exercises players solve most often on the first try.

  1. Identify the Key Parties Involved (ORDER BY, DISTINCT and LIMIT, 90% first try)
  2. Meet the suspects (ORDER BY, DISTINCT and LIMIT, 89% first try)
  3. Meet the cast (ORDER BY, DISTINCT and LIMIT, 88% first try)
  4. Who was paid to stage the fake hold-up? (LIKE, BETWEEN and IN, 85% first try)
  5. 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.

  1. What are each suspect's alibi details? (JOINs, 11% first try, 75 players)
  2. Which "Sheppard" family members were in the Study? (LIKE, BETWEEN and IN, 15% first try, 178 players)
  3. How many suspects claimed each alibi location between 4:45 and 5:15 AM (GROUP BY, COUNT and HAVING, 16% first try, 115 players)
  4. Who was in the Drawing Room or the Garden? (LIKE, BETWEEN and IN, 19% first try, 195 players)
  5. Who last saw Roger Ackroyd alive? (SELECT and WHERE, 19% first try, 164 players)
  6. Who never saw the victim alive? (JOINs, 19% first try, 59 players)
  7. Who Was in Compartment 4? (LIKE, BETWEEN and IN, 21% first try, 384 players)
  8. Identify the Passengers (SELECT and WHERE, 30% first try, 505 players)
  9. Who was at the vicarage? (LIKE, BETWEEN and IN, 34% first try, 44 players)
  10. When and where was everyone? (SELECT and WHERE, 44% first try, 435 players)

How to use these exercises

  1. Pick a skill above and read the exercise
  2. Write your query before you open the hint or the answer
  3. Click the button under the exercise to run your query in the case it comes from
  4. 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.

Start with Case 1 →

Keep going: How the game works  |  What you'll learn  |  SQL explained