Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Question about SQL Query

Question about SQL Query

From: nickli <ningli2000_at_hotmail.com>
Date: 13 Dec 2005 15:36:57 -0800
Message-ID: <1134517017.107449.295790@g14g2000cwa.googlegroups.com>


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 person
within 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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US