Chapter 9 · Interview Level
42. Order Date Gap Analysis
Hard40 XPE-Commerce
Find gaps in daily order activity: stretches of one or more days with no orders. For each gap, return the last date with orders before the gap (last_order_before_gap), the first date with orders after it (first_order_after_gap), and gap_days (the number of days between those two dates). Sort by last_order_before_gap.
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- order_dateTEXT
- statusTEXT
- total_amountREAL
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.