I have a scenario where each of my users buys two things from my shop, at different times.
+---------------------+----------+ | purchase_time | user_id | +---------------------+----------| | 2016-06-13 15:52:28 | 282725 | | 2016-05-15 15:35:04 | 282725 | | 2016-11-12 14:41:25 | 270307 | | 2016-10-17 15:01:64 | 270307 | | 2016-05-17 14:22:35 | 282085 | | 2016-02-11 14:38:31 | 282085 | +---------------------+----------+ What I'm trying to figure out is how long does it take (in terms of days/hours) between the initial purchase and the second purchase. I'm stumped on how to group each pair of purchases, do the subtraction, and then show it again on a per-user basis. Any advice?