Delivery evidence and route operations · Original fictional data · Free files and full answers
Attribute late units to carriers without counting packages as units
For each carrier return delivered_units,late_units and undelivered_units. Late means delivered_day>planned_day; NULL is undelivered rather than late. Sort carrier.
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
- For each carrier return delivered_units,late_units and undelivered_units. Late means delivered_day>planned_day; NULL is undelivered rather than late. Sort carrier.
- 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 carrier, delivered_units, late_units, undelivered_units. Sort order follows the task. Output has 2 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
- For each carrier return delivered_units,late_units and undelivered_units. Late means delivered_day>planned_day; NULL is undelivered rather than late. Sort carrier.
- For the first output record, carrier = X; delivered_units = 8; late_units = 0; undelivered_units = 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
Undelivered stock must be reported separately; NULL comparisons do not place it in the late bucket.
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 carrier,SUM(CASE WHEN delivered_day IS NOT NULL THEN units ELSE 0 END) delivered_units,SUM(CASE WHEN delivered_day>planned_day THEN units ELSE 0 END) late_units,SUM(CASE WHEN delivered_day IS NULL THEN units ELSE 0 END) undelivered_units FROM packages GROUP BY carrier ORDER BY carrier;
"carrier","delivered_units","late_units","undelivered_units" "X","8","0","0" "Y","6","4","1"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects