All challenges and every certification for $9 a month. And learn to build, buy and guide AI agents for supply chain: https://www.skool.com/supplychain

All game guides
Data Detective · Player guide

Answer the business from the data

Planning, customer service and finance send you questions. The answers are in a copy of the company's ERP, warehouse, transport and planning tables. You write SQL to find them, then type each answer in. The hard part is not the SQL: it is knowing which table holds the fact and spotting the numbers that look right but aren't.

You playData analystLength6 minutes for the intro, 18 to 22 for the othersQuestions5 to 8 per contract, 2 checks eachPass mark60 in every contract; 75 silver, 90 gold
Opened from a contract? This guide is in its own tab and your game is still in the other tab, exactly where you left it. Nothing you do here changes your run, so read as much as you like and switch back when you're ready.
Data Detective as it looks in a contract

Quick start

These steps get a pass on any Data Detective contract.

  1. Read the briefing on the left. Its tasks name the traps this database holds, such as cancelled lines or two units of measure.
  2. Browse the Tables panel. For each table read the system tag (ERP, WMS, TMS, CRM...), the description and the grain: what one row means. Press Columns to see the keys.
  3. Answer the landscape questions first. They are multiple choice and need no query; the descriptions and grains answer them.
  4. Look before you count. Click a table name to load SELECT * ... LIMIT 20, press Run query (or CtrlEnter), and read real rows. Then use the Group by snippet on the status column.
  5. Write the query, then check the number. Type it in the question's box and press Check. If it is wrong you have one more check: rethink the filter before you try again.
  6. Keep an eye on the Queries counter in the top bar. Staying at or under par keeps the efficiency part at full marks.
  7. Press Hand in the answers when every question is resolved, or when you are stuck. Unanswered questions score zero.

What the game is about

Each contract is one database and eight questions from the business. You can run queries and check answers in any order, and hand in once.

The loop

Read a question → find the table that holds the fact → look at a few rows → write the query → check the result against the traps → type the answer and press Check → read the explanation → next question → hand in.

What it teaches

Where supply chain data lives (item and supplier masters, stock by location and status, order and PO lines, receipts, shipments, forecasts), what one row of each table means, how keys join tables, and SQL for counts, sums, joins and rates such as on-time-in-full (OTIF) and forecast accuracy.

The twist

The database is real-world messy on purpose. Blocked stock, cancelled lines, partial receipts, duplicate suppliers, cases mixed with packs and four versions of every forecast all give a confident wrong number to a query that ignores them.

Reading the screen

The Tables panel is on the left, the SQL console on the right, and the questions below them. The briefing column sits on the far left until you hide it.

Top barAnswered, Points, Queries, Hints, plus the projected score. Queries turns red once you pass par; Hints turns red as soon as you use one.
Tables panelThe database name, what it holds and "Today is ...", the date the data was taken. Use that date, not today's real date, for anything late or overdue.
A table entryThe table name (click it to load a query), the source system tag, a Columns button, then the description, the grain ("One row per ...") and the number of rows.
Columns listEach column with its type (text, integer, real), its key (PK is the primary key, FK the link to another table) and a description. Click a column name to insert it at the cursor.
SQL consoleWrite one query at a time. The snippet buttons under it insert ready-made SQL. The counter next to Run query shows your queries against par.
Result gridUp to 100 rows, with a row count under it. Decimals are rounded to 4 places and empty values show as NULL. A red box shows an error instead.
History chipsYour last 8 queries, numbered. Click one to put it back in the console and show its result again. That doesn't count as a new query.
Question cardThe question kind and its points, a status tag ("2 checks left", "Correct", "Correct, second try" or "Not solved"), the question, the answer box and the Hint button. The left edge turns green or red when it is resolved.

From question to answer

Every question follows the same chain. Most wrong answers skip step 3.

1. Read the questionWhat exactly is asked: on hand or sellable? Lines or orders? Which period, which unit?
2. Find the tableWhich system records that fact, and what is one row of its table?
3. Look at real rowsLIMIT 20 and a GROUP BY on status show the traps before they bite.
4. Write the queryFilter, join on keys, then count or sum.
5. Check the answerType the number, code or choice and press Check.
Example: "How many hoses can we sell today?" The stock table has one row per warehouse, item, bin and stock status. Summing every row gives units on hand. Grouping by status first shows some units are blocked or in quarantine; only the available ones can be sold.

Question kinds

The small label at the top of each question card says its kind and its points. The kind decides which skill the question trains; for the score only the points matter.

Landscape

Shown as "landscape" on the card
Trains: landscape

Questions about the data itself: which table or system answers a question, what one row of a table means, or why the data is stored the way it is. Usually a multiple-choice question. It trains Knowing where supply chain data lives in your skill profile; in the score its points count like any other question's.

How to solve it: Read the table descriptions and the grain line in the Tables panel before you answer. You rarely need a query for these.

Lookup

Shown as "lookup" on the card
Trains: landscape

Find one number in one table, such as the stock of an item. The right table and the right filter are the whole job. It trains Knowing where supply chain data lives in your skill profile; in the score its points count like any other question's.

How to solve it: Run SELECT * on the table with a WHERE on the item first, look at every row, then SUM.

Join

Shown as "join" on the card
Trains: queries

The answer needs two tables linked by a key, for example an item and its supplier, or a PO line and its receipts. It trains Joining and aggregating data correctly in your skill profile; in the score its points count like any other question's.

How to solve it: Open both tables' Columns lists and find the column marked FK. Join on that key, never on a name.

Aggregate

Shown as "aggregate" on the card
Trains: queries

Counts, sums, averages and rates over many rows, often with a date range or a GROUP BY. It trains Joining and aggregating data correctly in your skill profile; in the score its points count like any other question's.

How to solve it: Check the filter before the maths: date range, status and units. Then compute the rate in one query so you don't round twice.

Trap

Shown as "trap" on the card
Trains: data quality

A question with a data-quality catch: blocked stock, cancelled lines, duplicate master records, mixed units or several forecast versions. The obvious query gives a wrong number. It trains Spotting data-quality traps in your skill profile; in the score its points count like any other question's.

How to solve it: Ask what the question really means (sellable, still to arrive, one company). Look at the status and the master data columns before you sum anything.

The SQL you can use

The console runs SQLite, one read-only query at a time, on a fresh copy of the data. A query can be up to 4,000 characters. Every query below works; the examples use tables from the Sandys Garden Tools contract, so swap in the names from your own Tables panel.

What you wantSQL that works hereGood to know
See a tableSELECT * FROM customers LIMIT 20Click a table name in the Tables panel to get this query in the console.
FilterSELECT * FROM sales_order_lines WHERE status = 'open' AND qty_ordered > 50= compares text exactly, capitals included. Text values go in single quotes.
Match part of a textSELECT * FROM item_master WHERE description LIKE '%hose%'LIKE ignores capitals; % stands for any text.
Count, sum, averageSELECT COUNT(*), SUM(qty_on_hand), AVG(qty_on_hand) FROM inventory_balanceMIN, MAX and TOTAL work too. There is no MEDIAN function.
Count different valuesSELECT COUNT(DISTINCT customer_id) FROM sales_order_linesHow many customers, items or suppliers appear.
Group and filter groupsSELECT customer_id, COUNT(*) FROM sales_order_lines GROUP BY customer_id HAVING COUNT(*) > 10HAVING filters after grouping; WHERE filters before.
Join two tablesSELECT s.order_id, c.name FROM sales_order_lines s JOIN customers c ON c.customer_id = s.customer_idJoin on the column marked FK in the Columns list.
Keep rows with no matchSELECT s.order_id, t.status FROM sales_order_lines s LEFT JOIN shipments t ON t.order_id = s.order_idMissing matches show as NULL. Test them with IS NULL.
Conditional countSELECT SUM(CASE WHEN qty_shipped < qty_ordered THEN 1 ELSE 0 END) FROM sales_order_linesIIF(condition, a, b) is a short form of CASE.
DatesSELECT order_id, julianday(promised_date) - julianday(requested_date) AS days FROM sales_order_linesdate(), strftime('%m', d) and date(d, '+7 days') also work. Use the database's "Today is" date, not your own.
Step-by-step queryWITH stock AS (SELECT item_id, SUM(qty_on_hand) AS qty FROM inventory_balance GROUP BY item_id) SELECT * FROM stock ORDER BY qty DESCWITH builds a temporary result you can query again. Ideal for per-line totals.
SubquerySELECT * FROM item_master WHERE item_id IN (SELECT item_id FROM purchase_order_lines WHERE status = 'open')A query inside a query.
RankingSELECT item_id, qty_on_hand, RANK() OVER (ORDER BY qty_on_hand DESC) FROM inventory_balanceWindow functions such as ROW_NUMBER and RANK work.
Rounding and decimalsSELECT ROUND(100.0 * 7 / 9, 1)Whole numbers divide to a whole number (7 / 9 = 0). Multiply by 100.0 or 1.0 first.
Missing valuesSELECT COALESCE(qty_shipped, 0) FROM sales_order_linesIFNULL does the same.
Stack resultsSELECT 'open', COUNT(*) FROM sales_order_lines WHERE status = 'open' UNION ALL SELECT 'all', COUNT(*) FROM sales_order_linesSeveral numbers side by side in one run.
Notes in a querySELECT COUNT(*) FROM customers -- one row per accountComments with -- or /* */ are fine.
Not allowed: anything that changes data (INSERT, UPDATE, DELETE, CREATE), PRAGMA, ATTACH, and two statements in one run. Results stop at 100 rows; the note under the grid says when rows were cut. Add a WHERE or a GROUP BY rather than scrolling.

Snippet buttons

The chips under the editor insert a template at the cursor. Hover a chip to see what it inserts. Replace table_name, column and the dates with real names.

ButtonInsertsUse it for
Count rowsSELECT COUNT(*) FROM table_name WHERE column = 'value'How many lines, orders or records match a filter.
SumSELECT SUM(column) FROM table_name WHERE column = 'value'Total units, value or quantity.
Group bySELECT column, COUNT(*), SUM(other_column) FROM table_name GROUP BY column ORDER BY 2 DESCA breakdown per status, warehouse or supplier. The best first look at any table.
JoinSELECT a.*, b.* FROM table_a a JOIN table_b b ON b.key = a.key LIMIT 20Link two tables on their key.
Date rangeWHERE date_column BETWEEN '2026-07-01' AND '2026-09-30'Keep one quarter or one period. Dates are text in YYYY-MM-DD form, so BETWEEN works.
DistinctSELECT DISTINCT column FROM table_nameSee every value a column takes, such as all statuses.
Days betweenjulianday(later_date) - julianday(earlier_date)Lead times and days late. The result is a number of days.
Case whenSUM(CASE WHEN condition THEN 1 ELSE 0 END)Count only the rows that meet a condition, inside a bigger query. The heart of every on-time rate.

When a query fails

Errors show in a red box under the console. A failed query still counts towards your query total, so read the message before you try again.

ExampleMessage you seeWhat to do
DELETE FROM customersOnly reading is allowed: this database is read-only.You tried to change data, create a table, use PRAGMA or ATTACH. Only SELECT (and WITH) queries run.
SELECT 1; SELECT 2SQL error: You can only execute one statement at a time.Two statements in one run. Run them one by one, or join them with UNION ALL.
SELECT * FROM stockSQL error: no such table: stockA typo or a table from another contract. Click the table name in the Tables panel instead of typing it.
SELECT item FROM item_masterSQL error: no such column: itemOpen the table's Columns list and click the column name to insert it.
SELECT MEDIAN(qty_on_hand) FROM inventory_balanceSQL error: no such function: MEDIANThe function doesn't exist in SQLite. Use the ones in the table above.
SELECT COUNT(*) FROM inventory_balance a, inventory_balance b, inventory_balance c, inventory_balance dThe query is too heavy and was stopped. Filter earlier, or join on the key columns.A join with no ON condition multiplies every row by every row. Add the key condition.

Classic data traps

Every contract hides some of these. The briefing's tasks usually name the ones that matter for that database.

Blocked and quarantined stock

Stock tables list every bin and every stock status. Units on hand are not units you can sell: blocked or quarantined lots are on the shelf but not available.

How to avoid it: GROUP BY the status column first to see what statuses exist, then filter on the sellable one.

Cancelled lines

Order and PO lines stay in the table when they are cancelled. Counting them inflates every total and every rate.

How to avoid it: Add WHERE status <> 'cancelled' (or whatever the status is called) to every count of lines.

Partial and split receipts

One PO line can be delivered in several receipts, and some receipts are short. "Received in full" means the sum of all receipts reaches the ordered quantity; "still to arrive" is ordered minus received on open lines.

How to avoid it: SUM the receipts per line in a WITH block first, then compare with the ordered quantity.

Duplicate master records

The same supplier or customer can exist twice, for example after a rushed onboarding or a change of address. Names differ slightly; the tax or VAT number is the same.

How to avoid it: GROUP BY the tax or VAT column and look for counts above 1. The newer record has the later creation date.

Mixed units of measure

Some customers order in cases, others in packs. Adding the quantities as they are mixes apples and boxes of apples.

How to avoid it: Join a conversion table on item and unit and multiply by the factor before you sum.

Several forecast versions

A forecast table can hold one row per target week for every time it was published (the lag). Summing all of them counts the same week four times.

How to avoid it: Filter on the one lag the question asks for, for example lag = 1.

Typing and checking answers

Each question has 2 checks. An empty box is not sent and doesn't use a check; a wrong answer does, even if you typed the same one before.

Number

A text box with the unit next to it. Type the number only: a dot for decimals (12.5), no thousands separator. A € or % sign and spaces are ignored. Most questions need the exact value; some rates, averages and euro values accept a small margin (0.6 of a point or €1 in the current contracts).

How to use it: Use ROUND(x, 1) in the query so you copy what the engine compares. Press Enter in the box to check.

Text

A code or a name, such as a supplier code or an item code. Capitals don't matter, but the spelling must match the database exactly. Where the question says "code or name", either is accepted.

How to use it: Copy the value from the result grid rather than typing it from memory.

Choice

Pick one option with the radio buttons, then press Check. Used for landscape questions about where data lives and what a row means.

How to use it: Think about the grain: what one row stands for usually decides the answer.

What a question pays

A question pays its points in full only when the first check is right. A hint costs 30% of the question's points whatever happens next.

ResultWithout hintWith hint (−30%)What the card shows
Right on the first check100%70%Explanation shown
Right on the second check60%42%Explanation shown
Wrong 2 times0%0%Right answer and explanation shown
Never checked0%0%Right answer shown after you hand in
Hints name the table or the trap. The Hint (−30% of points) button only shows while the question is open. If you are unsure, take it before your first check: a hinted answer that is right first time keeps 70%, more than the 60% of an unhinted answer that is right only on the second check.

Buttons & keys

Everything works with the mouse; two keys save time in the console and the answer boxes.

Tables panel

  • table nameReplaces the console text with SELECT * FROM that table LIMIT 20. It doesn't run it.
  • ColumnsHideShow or hide the table's columns, types, keys and descriptions.
  • column nameInserts the column name at the cursor. Hover it to read the description.

SQL console

  • Run queryRuns the query in the editor and adds it to your query count.
  • CtrlEnterRuns the query from inside the editor (CmdEnter on a Mac).
  • Count rowsGroup byJoinSnippet chips: insert a template at the cursor. There are eight; see the table above.
  • 1. SELECT ...Numbered history chips: reload a past query and its result, without running it again.

Question cards

  • CheckChecks the answer in the box or the selected option. Uses one of the question's checks.
  • EnterIn a number or text box: same as Check.
  • Hint (−30% of points)Shows a hint under the question and lowers what it can pay.

Top bar and finish

  • BriefingShow or hide the briefing column.
  • How to playOpens this guide in a new tab.
  • Sound onTurn sound effects on or off.
  • ExitLeave without handing in. Relaunching the contract starts a fresh run.
  • Hand in the answersSubmit. You can do it at any time, once. Every question then shows its answer and explanation.
  • ContinueReview runOn the debrief card after handing in: go back to where you started the contract, or open the run's record.

Scoring

Your score out of 100 is 85% answers and 15% efficiency. Every point counts the same, whatever kind of question it comes from, so one wrong answer costs about the same in every contract. The projected score in the top bar is the real score of your answers so far, with unanswered questions at zero.

PartWeightWhat counts
Answers85%Points earned as a share of all the contract's points. Right first time keeps all of a question's points, right on the second check 60%, and a hint takes 30% off what is left.
Getting there with few queries15%Your pace times the share of all points you earned. Pace is 100 while your query count is at or under par, then drops 50 points for every par's worth of extra queries, down to 30.
Gold needs every question right. One question wrong twice, or never checked, caps the score at 89, so it lands in silver at best. Par is set by the contract (10 to 30 queries) and shown next to Run query. Every run counts, including failed ones. Pass mark 60; stars at 60, 75, 90 points.

Tips & common mistakes

New to this game? Start with Kettle & Co: Your First Questions to the Database: four small tables and five questions, one idea at a time.
Read the grain line of every table first. "One row per warehouse, item, bin and stock status" tells you a plain SUM mixes statuses.
GROUP BY the status column before any count. It shows cancelled, blocked or closed rows in one query.
Build big answers in one query. A WITH block per line, then the rate on top, beats five small queries and rounding by hand.
Multiply by 100.0, not 100, when you compute a rate. Whole numbers divide to whole numbers in SQLite.
Use the history chips to go back to a good query instead of retyping and re-running it.
Take the hint before your first check when you are unsure. Hinted and right first time keeps 70%; unhinted and right second time keeps 60%.
Don't sum on-hand stock as sellable stock. Blocked and quarantined lots don't count.
Don't count cancelled lines in totals or in on-time rates.
Don't add cases to packs. Convert to the base unit first.
Don't use your computer's date for overdue questions. Use the database's "Today is" date.
Don't fire queries to see what happens. Every run counts against par, errors included.
Back to top