Difference between dates when grouping in SQL
Posted
by CeejeeB
on Stack Overflow
See other posts from Stack Overflow
or by CeejeeB
Published on 2010-03-24T15:53:19Z
Indexed on
2010/03/24
16:03 UTC
Read the original article
Hit count: 173
I have a table of purchases containing a user_id and a date_of_purchase.
I need to be able to select all the users who have made 2 purchases within 12 months of each other. The dates can be any point in time as long as they are less than 12 months apart.
e.g.
user_id date_of_purchase
123 01/Jan/2010
124 01/Aug/2010
123 01/Feb/2010
124 05/Aug/2008
In this example i want user_id 123
© Stack Overflow or respective owner