MySQL 5.6 Have a table which I query:
SELECT DISTINCT client, date_buy
FROM tickets
ORDER BY client, date_buy
Which gives me almost the result I need:
------------------------------
client | date_buy
-------------------------------
0027847524333 | 2018-06-13 16:03:43
0027847524333 | 2018-06-13 16:13:01
0027847524333 | 2018-06-18 22:03:01
0033652356025 | 2018-06-16 17:22:56
00353857861869 | 2018-08-13 17:37:56
What do I need to add to query so I could leave only clients where it has been more than 24h between orders?
Desired result:
------------------------------
client | date_buy
-------------------------------
0027847524333 | 2018-06-13 16:03:43
0027847524333 | 2018-06-18 22:03:01
0033652356025 | 2018-06-16 17:22:56
00353857861869 | 2018-08-13 17:37:56
Update: I would like to exclude repetitive sales for one customer that happened less than 24 hours each other.