Re: SQL Query (Joining the table to itself)

From: Ivars Grinbergs <ivars_at_power.it-riga.lv>
Date: 1996/01/26
Message-ID: <3108CD7D.4C1F_at_power.it-riga.lv>#1/1


Hello,
Pavan Muppidi wrote (sniped):  

Source data:
> frequency Thru_Date Status
> ------------------------------------------
> Monthly 01-JAN-96 C
> Monthly 01-FEB-96 I
> Monthly 01-MAR-96 I
> Monthly 01-APR-96 I
> Monthly 01-MAY-96 I
 Result needed:
> Frequency From_Date To_Date
> ----------------------------------------------
> Monthly 01-FEB-96 01-MAR-96
> Monthly 01-MAR-96 01-APR-96
> Monthly 01-APR-96 01-MAY-96
To get results exactly above, the following query could be used:   

SELECT frequency, from_date, add_months(from_date,1) to_date FROM your_table
WHERE from_date between '01-FEB-96' and '01-APR-96';   

Sincerely
Ivars Grinbergs



IT Riga Ltd., Oracle distributor in Latvia, ph. +371-7220281 fax.+371-7820173
             address: 14-23 Puskina str., Riga, Latvia, LV1003  
             e-mail:  ivars_at_power.it-riga.lv  
------------------------------------------------------------------------------
Received on Fri Jan 26 1996 - 00:00:00 CET

Original text of this message