Missing Invoice Serial Numbers
Problem
**[Classic — asked at multiple companies]**
The accounting team noticed gaps in invoice serial numbers.
Find all **missing serial numbers** between the minimum and maximum invoice IDs.
Return `missing_invoice_id`, ordered ascending.
Tables
Example rows — the live problem includes the full dataset.
invoices
| invoice_id |
|---|
Expected output
Your answer should return 2 rows with the columns missing_invoice_id.
Starter code (SQL)
SELECT *
FROM invoices;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock