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
Data Manipulation (SQL/Python)
Data Scientist
Amazon
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Medium

0

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
joins
deduplication
metric definition
DATE_TRUNC
LEFT JOIN
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. 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 Problems
Sample Answer
Clarify the Data
  • shipments is one row per shipment. delivery_promises can have several rows per shipment because promises are revised when a delay is detected. deliveries has at most one row per shipment and n...
Approach
  1. Deduplicate promises to one row per shipment. Joining the raw promises table would double count revised shipments.
  2. Inner join shipments to the original promise (a shipment without a promise is a...

Submit Your Answer
Markdown supported