▶ SQL Playground
Q11 HARD · Window Functions

Find gaps in sequential data

Given order IDs 1, 2, 3, 5, 6, 8, 9 — identify the missing IDs (4 and 7). Useful for finding deleted records or audit gaps.

Try this problem in the playground

The sample tables will be auto-loaded — write a query and run it instantly.

▶ Open Playground

Setup & sample data

The playground will create these tables and populate them automatically when you click "Open Playground" above:

Solutions

Multiple approaches — try each and understand the trade-offs.

Expected output