Runtyme
All practice problems

Data Engineering · SQL · Hard

SQL interview question: Ghost Orders

How many refunds point at orders that don't exist? Case 2: The Phantom Refunds. Refunds are up 400%. Orders aren't.

The problem

  • How many refunds point at orders that don't exist?

You'll use: SQL (SQLite) · SELECT & WHERE · JOIN · GROUP BY · TRIM & datetime() · Data cleaning

Solve it (expert level)3–6 min · You write SQL
Show a hint

The starter says 0. Check the raw orders table: SELECT * FROM orders; — anything odd at the bottom?

What this teaches (spoiler)

NOT IN and NULL don't mix: one NULL in the list makes NOT IN match nothing. For “rows with no match”, use NOT EXISTS or LEFT JOIN … IS NULL.

Bug of the Day: a new problem every midnight, free for everyone. Keep a streak with your friends.