A retention analyst wants to know how frequently repeat customers order:
orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER,
order_date TEXT -- 'YYYY-MM-DD'
)
Write a SQL query that returns, for every customer with at least two orders,
the average number of days between consecutive orders, rounded to 1 decimal
place. Two orders on the same day count as a 0-day gap. If a customer placed
orders on the same date, order them by order_id when computing gaps.
Return columns: customer_id, avg_days_between.
Order by customer_id ASC. Customers with a single order are excluded.