Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Concatenating records according to dates
"Marc" <marc.hast_at_dexia.be> wrote in message
news:c552081f.0410050635.3b2152ce_at_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.
could you post what you've tried and any errors you're getting?
++ mcs Received on Tue Oct 05 2004 - 10:28:40 CDT