Longest Gap Between a Customer's Orders

hard
Unit 24 · Window Functions & Cohorts0/0 to milestone

For each customer with at least two orders, return customer_id and max_gap_days: the largest number of days between two of their consecutive orders (in date order, ties by id). Sort by max_gap_days descending, then customer_id.

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
query.sql · SQLite
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Longest Gap Between a Customer's Orders · TechGradify