I want to find out how often my customers place an order within 7 days after their last order. I know how i can select customer ids, with the dates of their purchases, but how do i select the differences between these multiple dates? datediff probably, but how?
I am looking for a result like this:
customer_id, date1 | date2 | date3, diff date3-date2 | diff date2-date1
This is what I have now:
SELECT c.id,GROUP_CONCAT(DATE(co.date_order))
FROM customer c
JOIN customer_order co ON co.id_customer=c.id
GROUP BY c.id