← Inventory & Replenishment Exceptions

Independent practice · SQLite

Flag replenishment actions

Practice dataset

My saved work →

Your work

Active 0:00 · Paused 0s

Keep a handoff you can replay

Check your current answer, then download the output and its report. The report includes the source, answer and each check so you can review what passed and what needs work.

To replay your work, open this task with the same dataset, import your answer and check it again.

Show the reference answer
WITH clean_inbound AS (SELECT DISTINCT p.* FROM inbound p WHERE NOT EXISTS (SELECT 1 FROM inbound x WHERE x.po_id=p.po_id AND (x.sku<>p.sku OR x.units<>p.units OR x.eta<>p.eta OR x.status<>p.status))), due AS (SELECT sku,SUM(units) AS due_units FROM clean_inbound WHERE status='confirmed' AND eta<='2026-10-07' GROUP BY sku), positions AS (SELECT s.*,s.on_hand-s.reserved AS available,COALESCE(d.due_units,0) AS due_units,s.on_hand-s.reserved+COALESCE(d.due_units,0) AS position FROM stock s LEFT JOIN due d ON s.sku=d.sku) SELECT sku,CASE WHEN on_hand IS NULL THEN 'recount' WHEN available<0 THEN 'resolve_reservations' WHEN position<reorder_point THEN 'reorder' ELSE 'hold' END AS action FROM positions ORDER BY sku

Changing the CASE order can incorrectly order a product whose reservation count is invalid.