Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create new rows from overlapping date ranges

3407341Mar 1 2017 — edited Mar 10 2017

Hi all -

I'm a bit new to Oracle SQL so I don't know all the best tips and tricks to accomplish what I need to do - given date ranges of different categories, I need to remove any dates from the first category which overlap with the 2nd.  So, say I have

Range 1: CAT_A, 2017-01-01 to 2017-01-14

Range 2: CAT_B, 2017-01-07 to 2017-01-12

I need to end up with:

CAT_A, 2017-01-01 to 2017-01-06

CAT_B, 2017-01-07 to 2017-01-12

CAT_A, 2017-01-13 to 2017-01-14

And to further complicate things there could also be more than one Category B record to work with.  Category B records could also be a single day.  Any help would be much obliged.

This post has been answered by Stew Ashton on Mar 1 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 7 2017
Added on Mar 1 2017
8 comments
1,865 views