Re: Query Logic

From: <sybrandb_at_hccnet.nl>
Date: Tue, 16 Sep 2008 22:58:57 +0200
Message-ID: <6a70d4h45c9aqevqp8vi2locfk8fa05njj@4ax.com>


On Tue, 16 Sep 2008 12:29:58 -0700 (PDT), exec_at_chicagorsvp.com wrote:

>
>Hi All,
>
>We've got this data:
>
>FLAG DATE MEMBER_ID
>-- --------- -----------
>A 12-SEP-08 1072604574
> I 03-DEC-07 1072604574
>A 09-MAR-07 1072604574
>
>What we want to do is the increment seperate counters for each month
>in which the member was active, shows by the letter A.
>
>This data shows that the customer was active on 9/9/07. He
>inactivated himself on 12/3/07. Then, he reactivted himself on
>9/12/08.
>
>So, we want to have seperate counters for the months the member was
>active, which means March/07 thru November /07, then again on
>Septermber/08.
>
>Not sure how to actually catch the months between the time he
>activated and inactivated. Trying a bunch of IF/ELSE statements, but
>that is getting just too crazy to code.......
>
>Any thoughts on this? Even tried a loop for each month, but even that
>does not work because even though there is no entry, he was active in
>May of 07........
>
>Much Regard

Apparently you are mtek.
Please don't post the same homework using two different email accounts or nicks.
Did you try anything? Apparently not.
Joining the table with itself, or using the LAG datawarehouse function, you should be able to get the 'previous' record, and calculate the number of months between two dates.

Yes, this answer does require reading documentation, it does require you to do some work, and you badly want others to do your homework for free; I won't fall into that trap.

-- 
Sybrand Bakker
Senior Oracle DBA
Received on Tue Sep 16 2008 - 15:58:57 CDT

Original text of this message