RE: friday afternoon brain fog -> SQL question

From: Stephens, Chris <Chris.Stephens_at_adm.com>
Date: Fri, 20 Mar 2015 15:55:29 -0500
Message-ID: <D95BD5AFADBB0F4E9BB6C53F14D3A05013E224E457_at_JRCEXC1V1.research.na.admworld.com>



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_at_gmail.com] Sent: Friday, March 20, 2015 3:40 PM
To: rjanuary_at_gmail.com
Cc: Stephens, Chris; oracle-l_at_freelists.org 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_at_gmail.com<mailto:rjanuary_at_gmail.com>> wrote: I apologize, right after hitting send I noticed your last two sentences.

On Mar 20, 2015, at 3:29 PM, Ryan January <rjanuary_at_gmail.com<mailto:rjanuary_at_gmail.com>> 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_at_adm.com<mailto:Chris.Stephens_at_adm.com>> 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.

--

http://www.freelists.org/webpage/oracle-l Received on Fri Mar 20 2015 - 21:55:29 CET

Original text of this message