Value each issue at its chronological moving weighted cost Original fictional practice · CC BY 4.0 · 2026-11-11 TASK Interleave receipts before issues on the same day, by id. A receipt adds quantity and acquisition value; an issue consumes up to available quantity at the current average. Return issue_id,moving_unit_cost,covered_units,moving_cogs_cents, money rounded2. Sort issue_id. OUTPUT issue_id, moving_unit_cost, covered_units, moving_cogs_cents RULES Interleave receipts before issues on the same day, by id. A receipt adds quantity and acquisition value; an issue consumes up to available quantity at the current average. Return issue_id,moving_unit_cost,covered_units,moving_cogs_cents, money rounded2. Sort issue_id. Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero. These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ. FIELD DICTIONARY lots: id INTEGER — Stable source record identifier; not a row position. sku TEXT — Literal business key or category label. Match exactly and retain NULL where present. received INTEGER — Lot receipt day index. expiry INTEGER — Lot expiration day; issue on or after this day is expired. units INTEGER — Physical unit quantity, not a monetary amount. cost INTEGER — Acquisition cost in integer cents per physical unit. issues: id INTEGER — Stable source record identifier; not a row position. sku TEXT — Literal business key or category label. Match exactly and retain NULL where present. day INTEGER — Integer day index, or ISO YYYY-MM-DD date when stored as text; the task declares cutoff semantics. units INTEGER — Physical unit quantity, not a monetary amount. transfers: id INTEGER — Stable source record identifier; not a row position. pair_id TEXT — Foreign business-record identifier; match to the named source key. warehouse TEXT — Literal business key or category label. Match exactly and retain NULL where present. delta INTEGER — Signed movement: positive adds, negative removes. METHOD Interleave receipts before issues on the same day, by id. A receipt adds quantity and acquisition value; an issue consumes up to available quantity at the current average. Return issue_id,moving_unit_cost,covered_units,moving_cogs_cents, money rounded2. Sort issue_id. For the first output record, issue_id = 1; moving_unit_cost = 108.89; covered_units = 6; moving_cogs_cents = 653.33. Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV. COMMON WRONG TURN A final weighted purchase price leaks later receipts into earlier issues; FIFO is a different cost flow policy. RESULT CHECK For the first output record, issue_id = 1; moving_unit_cost = 108.89; covered_units = 6; moving_cogs_cents = 653.33. Use setup.sql in a fresh SQLite database and run your own SELECT or WITH. reference.sql and expected.csv contain the full worked answer. All CSVs have UTF-8 headers; empty output fields represent NULL. The browser executes SQLite, not Excel formulas. No spreadsheet function engine is claimed.