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 -> Re: Question about SQL Query

Re: Question about SQL Query

From: Rene Nyffenegger <rene.nyffenegger_at_gmx.ch>
Date: Thu, 15 Dec 2005 22:18:07 +0000 (UTC)
Message-ID: <dnsq2v$u9a$1@nntp.init7.net>


On 2005-12-13, nickli <ningli2000_at_hotmail.com> wrote:
> 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

I have written about a similar problem here: http://www.adp-gmbh.ch/blog/2005/november/28.html

hth,
Rene

-- 
  Rene Nyffenegger
  http://www.adp-gmbh.ch/
Received on Thu Dec 15 2005 - 16:18:07 CST

Original text of this message

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