cools maths gamesSurprise me

SQL Detective Mystery

Crack a murder case in SQL City by querying a real database of people, interviews and records.

SQL Detective Mystery title screen
  • Partly works on mobile
Report a problem

SQL Detective Mystery turns a database into a crime file. Someone was killed in SQL City, the report is dated January 15, 2018, and you only recall that a crime scene report was filed. Witnesses, gym visits, car records and more all hide in tables. Your goal is to name the killer using SQL that runs right in the page.

How SQL Detective Mystery Works

The page holds a set of code boxes. Each starts with a sample query that you are free to change, and running it prints a results table beneath. The opening boxes reveal the table names and the column layout of a chosen table.

The trail starts with the crime scene report. That report points to witnesses. Find their records, read what each one told police, and you get leads such as a membership and a vehicle to chase through other tables.

Once you have a suspect, enter the name in the answer box at the bottom and run it. A correct guess unlocks a tougher follow-up.

Your First Few Minutes

  1. If SQL is new to you, open the walkthrough link first.
  2. Run the starting queries to see the table names.
  3. Open the database diagram to see how tables connect.
  4. Filter the crime scene reports by date, city and type.
  5. Follow the witnesses into the interview table and keep notes.

Controls for SQL Detective Mystery

Keyboard, mouse and touch controls for SQL Detective Mystery
To do thisKeyboardMouseTouch screen
Type or edit a queryType in the code boxClick inside a code boxTap a code box to bring up the keyboard
Run the query in a boxShift + EnterClick RunTap Run
Put the box back to its starting querynot usedClick ResetTap Reset
Show the database diagramnot usedClick the "click here" link above the last code boxTap the "click here" link
Reveal a suggested query (walkthrough page)not usedClick Show SolutionTap Show Solution

What It Trains

This is hands-on coding. You write real queries, read the output and adjust, just as you would with any database. Each clue turns into a filter or a join.

It also trains logical thinking. You build a case step by step, ruling people out until only one fits all the facts.

Strategy Notes

  • Check the schema early. The diagram maps which ID columns connect people to licenses, statements and gym records.
  • Narrow with WHERE. Pin down the type, the city and the date and over a thousand reports shrink to one.
  • Match loose names with LIKE. Some people are described only partly, so a pattern with % wildcards beats an exact match.
  • Sort for extremes. Sorting in descending order and keeping one row finds the highest address number.
  • Join tables in one query. Linking tables lets a single query test several clues at once.

Good to Know

The data set covers roughly 10,000 residents and more than a thousand reports, all running locally in the browser. Typing is easiest with a real keyboard. The case was made by NUKnightLab and is shared under CC BY-SA 4.0.

SQL Detective Mystery questions and answers

Is SQL Detective Mystery too hard for a beginner?

No. A walkthrough page teaches the main commands, from picking columns to filtering, counting and linking tables, with example boxes you can run. It can show a suggested query when you are stuck, and the full case can be cracked right on that page.

How do I check my answer?

Swap the placeholder in the final box for a suspect's full name and run that query. The database itself replies, telling you if you are wrong or confirming the culprit and pointing you onward.

What is the bonus challenge?

A correct answer reveals that someone else was pulling the strings. Your new job is to track down that person, and the game challenges you to manage it using no more than two queries.

Can I save my progress?

No. Everything lives inside the open tab, and refreshing puts every box back to its starting query. Keep a notepad handy for the names, ID numbers and dates you uncover along the way.

Games that use coding like SQL Detective Mystery

Different rules, same kind of thinking.

Try something from another shelf