How to split one column with dates into two with periods (from-to) [message #675563] |
Sat, 06 April 2019 09:37 |
|
chrisk4@wp.pl
Messages: 7 Registered: April 2019
|
Junior Member |
|
|
Hello,
I'm very 'green' in oracle so forgive for obvious question but i've got problem with split one column into periods (for each ID)
My source table look like this:
ID DATE SEL1 SEL2 SEL3 SEL3 SEL4 SEL5 SEL6 SEL7 SEL8
100095 2004-07-01 N N N N T N N N N
100095 2005-01-01 N N N N N N N N N
100096 2004-07-01 T T N T T N N N N
100096 2004-08-01 N N N N N N N N N
100097 2004-07-01 N N N N T N N N N
100097 2004-08-01 N N N N N N N N N
100098 2004-07-01 N N N N T N N N N
100098 2004-08-01 N N N N N N N N N
And want to archieve this result:
ID DATE_FROM DATE_TO SEL1 SEL2 SEL3 SEL3 SEL4 SEL5 SEL6 SEL7 SEL8
100095 2004-07-01 2004-12-31 N N N N T N N N N
100095 2005-01-01 N N N N N N N N N
100096 2004-07-01 2004-07-31 T T N T T N N N N
100096 2004-08-01 N N N N N N N N N
100097 2004-07-01 2004-07-31 N N N N T N N N N
100097 2004-08-01 N N N N N N N N N
100098 2004-07-01 2004-07-31 N N N N T N N N N
100098 2004-08-01 N N N N N N N N N
In Above example i've got 2 periods but it could be more - periods for each ID should start and end without gaps - last value is empty (DATE_TO) (alternatively i would like to know how to put value in last DATE_TO)
Thanks in advance for reply
Regards
*BlackSwan added {code} tags. Please do so your self in the future.
[Updated on: Sat, 06 April 2019 09:57] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|