inventory_moves holds stock movements (positive = inbound, negative = outbound); a SKU can have several moves on the same day. End-of-day stock = opening_stock + all moves up to and including that day. For each SKU find the first move_date on which end-of-day stock is strictly below its reorder_point (a dip inside a day that is restocked the same day does not count). Return sku, breach_date and stock_on_hand (end-of-day stock that day). SKUs that never breach are excluded. Order by breach_date, then sku.
| Column | Type |
|---|---|
| sku | TEXT |
| opening_stock | INTEGER |
| reorder_point | INTEGER |
| sku | opening_stock | reorder_point |
|---|---|---|
| SKU-A | 100 | 30 |
| SKU-B | 50 | 20 |
| SKU-C | 40 | 10 |
| SKU-D | 10 | 5 |
| SKU-E | 25 | 25 |
| Column | Type |
|---|---|
| move_id | INTEGER |
| sku | TEXT |
| move_date | DATE |
| qty | INTEGER |
| move_id | sku | move_date | qty |
|---|---|---|---|
| 1 | SKU-A | 2026-05-01 | -40 |
| 2 | SKU-A | 2026-05-02 | -25 |
| 3 | SKU-A | 2026-05-03 | -10 |
| 4 | SKU-A | 2026-05-04 | 50 |
| 5 | SKU-B | 2026-05-01 | -20 |
| 6 | SKU-B | 2026-05-02 | -15 |
| 7 | SKU-C | 2026-05-01 | -20 |
| 8 | SKU-C | 2026-05-03 | -5 |
| sku | breach_date | stock_on_hand |
|---|---|---|
| SKU-B | 2026-05-02 | 15 |
| SKU-A | 2026-05-03 | 25 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ First-Touch vs Last-Touch Attribution · Top Suppliers' Share of Category GMV ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.