Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Question about SQL Query
Hi,
I was able to solve the following problem using PL/SQL. However I would like to know if it can be solved using a SQL query:
The table has these columns: user_id, purchase_date I would like to count the number of store visits by a personwithin a calendar year. Purchase_dates within a rolling 7 day period are counted as one store visit. There can be several or no purchases within these 7 days. Next purchase date can start any time. For example:
Purchase_Date: 11/1/2005, 11/3/2005, 11/11/2005, 12/1/2005, 12/5/2005, 12/18/2005
Number of Visits = 4 11/1/2005 and 11/3/2005 count as one visit 11/11/2005 counts as one visit 12/1/2005 and 12/5/2005 count as one visit 12/18/2005 counts as one visit
Thanks in advance.
Nick Li Received on Tue Dec 13 2005 - 17:36:57 CST