RE: friday afternoon brain fog -> SQL question

  • From: "Stephens, Chris" <Chris.Stephens@xxxxxxx>
  • To: Andrew Kerber <andrew.kerber@xxxxxxxxx>, "rjanuary@xxxxxxxxx" <rjanuary@xxxxxxxxx>
  • Date: Fri, 20 Mar 2015 15:55:29 -0500

misery loves company.

i though for sure i'd have a solution in 5 minutes with all the sql expertise 
out there.  that's assuming there is a sql solution and i'm not sure that's a 
safe assumption.
________________________________________
From: Andrew Kerber [andrew.kerber@xxxxxxxxx]
Sent: Friday, March 20, 2015 3:40 PM
To: rjanuary@xxxxxxxxx
Cc: Stephens, Chris; oracle-l@xxxxxxxxxxxxx
Subject: Re: friday afternoon brain fog -> SQL question

This is a serious brain teaser, and you send it at 330 central time on a 
Friday.  Are you trying to keep us awake thinking about all weekend?

On Fri, Mar 20, 2015 at 3:31 PM, Ryan January 
<rjanuary@xxxxxxxxx<mailto:rjanuary@xxxxxxxxx>> wrote:
I apologize, right after hitting send I noticed your last two sentences.

On Mar 20, 2015, at 3:29 PM, Ryan January 
<rjanuary@xxxxxxxxx<mailto:rjanuary@xxxxxxxxx>> wrote:

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<mailto: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.





--
Andrew W. Kerber

'If at first you dont succeed, dont take up skydiving.'

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.


--
//www.freelists.org/webpage/oracle-l


Other related posts: