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 -> Concatenating records according to dates

Concatenating records according to dates

From: Marc <marc.hast_at_dexia.be>
Date: 5 Oct 2004 07:35:42 -0700
Message-ID: <c552081f.0410050635.3b2152ce@posting.google.com>


I need a simple query to concatenate periods for a given subsidiary and manager.
Up to now a simple group by was all I needed. This group by fails in the some cases given below (subsidiary 200 and 210).

Data:
sub mgr startdate enddate
--- --- --------- -------

100 1   2003-01-01 2003-03-15
100 1   2003-03-15 2003-11-30
200 1   2003-01-01 2003-07-01
200 2   2003-07-01 2004-01-01
200 1   2004-01-01 2004-02-01
210 1   2003-01-01 2003-06-01
210 1   2003-06-01 2003-10-01
210 2   2004-01-01 2004-02-01
210 3   2004-02-01 2004-03-01
210 2   2004-03-01 2004-04-01
210 2   2004-04-01 2004-05-01
210 2   2005-05-01 2005-06-01

Wanted result:
sub mgr startdate enddate
--- --- --------- -------

100 1   2003-01-01 2003-11-30
200 1   2003-01-01 2002-07-01
200 2   2003-07-01 2004-01-01
200 1   2004-01-01 2004-02-01
210 1   2003-01-01 2003-10-01
210 2   2004-01-01 2004-02-01
210 3   2004-02-01 2004-03-01
210 2   2004-03-01 2005-06-01

It seems simple but without using cursors I don't see any solution. Can someone sort this out ?
Any help is very much appreciated. Thanks. Received on Tue Oct 05 2004 - 09:35:42 CDT

Original text of this message

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