← Inventory & Replenishment Exceptions

Independent practice · SQLite

Build projected stock positions

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,available,due_units,position FROM positions ORDER BY sku

COALESCE belongs on the missing inbound total; putting it on physical stock invents a measurement.