Calculate approval slack before a quote or delivery deadline
Original fictional practice · CC BY 4.0 · 2026-11-11

TASK
Approval day8 and delivery deadline14. For each A bid return bid_id,expiry_slack=expires-8,delivery_slack=14-8-lead_days,limiting_slack=min. Negative means already infeasible. Sort bid_id.

OUTPUT
bid_id, expiry_slack, delivery_slack, limiting_slack

RULES
Approval day8 and delivery deadline14. For each A bid return bid_id,expiry_slack=expires-8,delivery_slack=14-8-lead_days,limiting_slack=min. Negative means already infeasible. Sort bid_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
bids:
  id INTEGER — Stable source record identifier; not a row position.
  supplier TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  sku TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  unit_cents INTEGER — Exact integer monetary cents; no implicit currency conversion.
  shipping INTEGER — Fixed supplier order freight in cents.
  capacity INTEGER — Maximum quantity this bid can supply.
  moq INTEGER — Minimum nonzero order quantity.
  lead_days INTEGER — Elapsed delivery lead time in days.
  expires INTEGER — Expiry boundary; the goal declares whether equality is eligible.
  risk_low INTEGER — Lower supplier-level risk allowance in cents.
  risk_high INTEGER — Upper supplier-level risk allowance in cents.

kit:
  sku TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  units INTEGER — Physical unit quantity, not a monetary amount.

amendments:
  line TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  old_units INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.
  new_units INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.
  unit_cents INTEGER — Exact integer monetary cents; no implicit currency conversion.

METHOD
Approval day8 and delivery deadline14. For each A bid return bid_id,expiry_slack=expires-8,delivery_slack=14-8-lead_days,limiting_slack=min. Negative means already infeasible. Sort bid_id.
For the first output record, bid_id = 1; expiry_slack = 12; delivery_slack = 3; limiting_slack = 3.
Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.

COMMON WRONG TURN
Quote validity alone does not show whether enough delivery lead time remains.

RESULT CHECK
For the first output record, bid_id = 1; expiry_slack = 12; delivery_slack = 3; limiting_slack = 3.

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.
