SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Average Days Between Orders

Unsolved

Shopify merchants want to know how often repeat customers come back. For each customer, consider their orders sorted by `order_date` (with `order_id` breaking ties on the same day) and compute the number of days between each order and the one before it. Return `customer_id`, `orders_count` (total orders) and `avg_days_between_orders` (average of those gaps, rounded to 2 decimals) for customers with at least 2 orders. Order the results by `customer_id` ascending.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Amazon🏢 Shopify🏢 Etsy

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM customer_orders
Full source dataset
13 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine