Weekly Delivery Promise Accuracy by Region Using the Original Promise
Last updated: November 29, 2026
Quick Overview
Using shipments (shipment_id, region, ship_date), delivery_promises (shipment_id, promised_date, promise_created_at, possibly several per shipment) and deliveries (shipment_id, delivered_date), compute weekly promise accuracy by region: the share of shipments delivered on or before the first date promised to the customer.
Amazon
November 29, 20260
0
0 solved
Using shipments (shipment_id, region, ship_date), delivery_promises (shipment_id, promised_date, promise_created_at, possibly several per shipment) and deliveries (shipment_id, delivered_date), compute weekly promise accuracy by region: the share of shipments delivered on or before the first date promised to the customer.
Delivery promise accuracy is one of the metrics Amazon's transportation and fulfillment org obsesses over, because a missed promise directly hurts customer trust. Onsite interviewers use this to test join choices (promises get revised, deliveries can be missing) and whether the metric definition resists gaming by re-promising.
What the Interviewer Expects
- Pick the original promise per shipment with ROW_NUMBER, and justify it over the latest revision
- Use a LEFT JOIN to deliveries so undelivered shipments stay in the denominator
- Separate not-yet-delivered from late in the output
- Bucket by ship week with DATE_TRUNC and state the week start
- Avoid fan-out from joining a one-to-many promises table directly
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would the metric change if you used the latest promise, and why is that risky?
- How would you exclude the current week where many shipments are still in flight?
- How would you attribute misses to the carrier leg vs the fulfillment center leg?
- How would you show accuracy at the zip code level without tiny sample sizes misleading people?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
shipmentsis one row per shipment.delivery_promisescan have several rows per shipment because promises are revised when a delay is detected.deliverieshas at most one row per shipment and n...
Approach
- Deduplicate promises to one row per shipment. Joining the raw promises table would double count revised shipments.
- Inner join shipments to the original promise (a shipment without a promise is a...