Re: friday afternoon brain fog -> SQL question

  • From: Ryan January <rjanuary@xxxxxxxxx>
  • To: Chris.Stephens@xxxxxxx
  • Date: Fri, 20 Mar 2015 15:29:46 -0500

I think a little more detail may be required for a full solution.  

What constitutes an overlap?
Do overlapping values share a common ID?  If so, wouldn't you be looking for 
min(start_date) and max(end_date)?


> On Mar 20, 2015, at 3:24 PM, Stephens, Chris <Chris.Stephens@xxxxxxx> wrote:
> 
> I am trying to coalesce a table with many overlapping intervals of start/end 
> dates for every ID so that any overlapping ranges for any particular ID are 
> merged.  I’ve started down the PL/SQL route but I was thinking that 1) there 
> might be a pure SQL solution and 2) someone on this list has already solved 
> or would much more quickly solve this than me.
>  
> Oracle 11.2.
>  
> Table T
> =============
> ID NUMBER
> START_DATE DATE
> END_DATE   DATE
>  
> There are many overlapping ranges for any particular ID and there are many 
> non-overlapping ranges for any particular ID.  I want to merge the 
> overlapping ranges.
>  
> Any help?
>  
>  
> 
> CONFIDENTIALITY NOTICE:
> This message is intended for the use of the individual or entity to which it 
> is addressed and may contain information that is privileged, confidential and 
> exempt from disclosure under applicable law. If the reader of this message is 
> not the intended recipient or the employee or agent responsible for 
> delivering this message to the intended recipient, you are hereby notified 
> that any dissemination, distribution or copying of this communication is 
> strictly prohibited. If you have received this communication in error, please 
> notify us immediately by email reply.

Other related posts: