Delivery evidence and route operations · Original fictional data · Free files and full answers
Classify on-time-in-full at the order grain
An order is OTIF only when units delivered by its planned day meet required_units. Return order_id,on_time_units,otif flag sorted order_id. Late units cannot repair this historical metric.
Use this fixed business case to build a checked CSV and a replayable SQL handoff. No account required. Scenario datasets are shared across related exercises; each exercise has its own decision and output contract.
Your output contract
- An order is OTIF only when units delivered by its planned day meet required_units. Return order_id,on_time_units,otif flag sorted order_id. Late units cannot repair this historical metric.
- 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.
Return columns exactly as order_id, on_time_units, otif. Sort order follows the task. Output has 5 rows; an empty CSV field means NULL.
Source data
packages
7 source rows · Download packages CSV
| id INTEGER | order_id INTEGER | planned_day INTEGER | delivered_day INTEGER | units INTEGER | required_units INTEGER | carrier TEXT |
|---|---|---|---|---|---|---|
| 1 | 1 | 3 | 2 | 2 | 5 | X |
| 2 | 1 | 3 | 4 | 3 | 5 | Y |
| 3 | 2 | 4 | 4 | 4 | 4 | X |
| 4 | 3 | 5 | NULL | 1 | 3 | Y |
| 5 | 3 | 5 | 5 | 2 | 3 | Y |
| 6 | 4 | 6 | 5 | 2 | 2 | X |
| 7 | 5 | 6 | 7 | 1 | 2 | Y |
attempts
10 source rows · Download attempts CSV
| id INTEGER | package_id INTEGER | minute INTEGER | result TEXT |
|---|---|---|---|
| 1 | 1 | 100 | success |
| 2 | 2 | 120 | failed |
| 3 | 2 | 200 | success |
| 4 | 3 | 80 | success |
| 5 | 4 | 150 | failed |
| 6 | 4 | 240 | failed |
| 7 | 5 | 160 | success |
| 8 | 6 | 200 | success |
| 9 | 7 | 300 | failed |
| 10 | 7 | 500 | success |
stops
6 source rows · Download stops CSV
| route TEXT | seq INTEGER | arrive INTEGER | depart INTEGER | load_delta INTEGER | kind TEXT | pair_id TEXT |
|---|---|---|---|---|---|---|
| R | 1 | 0 | 10 | 5 | pickup | A |
| R | 2 | 30 | 40 | 4 | pickup | B |
| R | 3 | 60 | 75 | -5 | drop | A |
| R | 4 | 90 | 95 | -4 | drop | B |
| S | 1 | 0 | 5 | -2 | drop | C |
| S | 2 | 20 | 30 | 2 | pickup | C |
proofs
5 source rows · Download proofs CSV
| package_id INTEGER | kind TEXT |
|---|---|
| 1 | signature |
| 2 | photo |
| 3 | signature |
| 5 | scan |
| 6 | signature |
Field dictionary and schema
packages: id INTEGER — Stable source record identifier; not a row position. order_id INTEGER — Foreign business-record identifier; match to the named source key. planned_day INTEGER — Day index or ISO date as declared in this task; preserve its source representation. delivered_day INTEGER — Day index or ISO date as declared in this task; preserve its source representation. units INTEGER — Physical unit quantity, not a monetary amount. required_units INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task. carrier TEXT — Literal business key or category label. Match exactly and retain NULL where present. attempts: id INTEGER — Stable source record identifier; not a row position. package_id INTEGER — Foreign business-record identifier; match to the named source key. minute INTEGER — Elapsed UTC minute from the fictional scenario origin. result TEXT — Literal business key or category label. Match exactly and retain NULL where present. stops: route TEXT — Literal business key or category label. Match exactly and retain NULL where present. seq INTEGER — Declared event or route sequence, ascending within its owner. arrive INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task. depart INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task. load_delta INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task. kind TEXT — Literal business key or category label. Match exactly and retain NULL where present. pair_id TEXT — Foreign business-record identifier; match to the named source key. proofs: package_id INTEGER — Foreign business-record identifier; match to the named source key. kind TEXT — Literal business key or category label. Match exactly and retain NULL where present.
A method you can reuse
- An order is OTIF only when units delivered by its planned day meet required_units. Return order_id,on_time_units,otif flag sorted order_id. Late units cannot repair this historical metric.
- For the first output record, order_id = 1; on_time_units = 2; otif = 0.
- Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.
Watch for this wrong turn
Average package timeliness can label an order successful even when the missing units are essential.
Run and check in SQLite
Your SQL runs locally in the existing SQLite worker. The checker compares every column, row, type, value and row order with this fixed output. It accepts equivalent SELECT or WITH queries. Browser storage keeps your SQL on this device when available.
Complete worked SQL and expected output
SELECT order_id,SUM(CASE WHEN delivered_day<=planned_day THEN units ELSE 0 END) on_time_units,SUM(CASE WHEN delivered_day<=planned_day THEN units ELSE 0 END)>=MAX(required_units) otif FROM packages GROUP BY order_id ORDER BY order_id;
"order_id","on_time_units","otif" "1","2","0" "2","4","1" "3","2","0" "4","2","1" "5","0","0"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects