get rid of lines that are completely understood by the other lines

using oracle 10 g

I have a requirement where I have a few groups that have a start date and end date, and
I don't know how many lines per group, it is dynamic.

I need to get rid of all the lines that are completely understood by the other lines per group
To tell if an online group has started on January 1, 2000 and ending on January 1, 2001
and another group line begins February 1, 2000 and ends at 2000 1 dec
only the line Jan to Jan should appear.

so, for
with t as
(
    select 'A' grp, 1 id, to_date('01-01-2000', 'MM-DD-YYYY') start_dt, to_date('01-01-2001', 'MM-DD-YYYY') end_dt from dual union all
    select 'A' grp, 2 id, to_date('02-01-2000', 'MM-DD-YYYY') start_dt, to_date('12-01-2000', 'MM-DD-YYYY') end_dt from dual union all
    select 'A' grp, 3 id, to_date('03-01-2000', 'MM-DD-YYYY') start_dt, to_date('12-10-2000', 'MM-DD-YYYY') end_dt from dual union all
    select 'A' grp, 4 id, to_date('07-01-2000', 'MM-DD-YYYY') start_dt, to_date('01-10-2001', 'MM-DD-YYYY') end_dt from dual union all
    select 'A' grp, 5 id, to_date('01-01-2000', 'MM-DD-YYYY') start_dt, to_date('01-01-2001', 'MM-DD-YYYY') end_dt from dual 
 )
I don't want to see
GRP,ID,START_DT,END_DT
A,1,1/1/2000,1/1/2001
A,4,7/1/2000,1/10/2001
Published by: pollywog on July 20, 2010 11:49

Published by: pollywog on July 20, 2010 11:56

Published by: pollywog on July 20, 2010 11:56

Well, I do not get the exact release you do, but I'm sure that this complies with your verbal condition.

You may have a fault in your output specified? It is also quite possible, that there is something wrong with my query :)

with
   t as
(
   select 'A' grp, 1 id, to_date('01-01-2000', 'MM-DD-YYYY') start_dt, to_date('01-01-2001', 'MM-DD-YYYY') end_dt from dual union all
   select 'A' grp, 2 id, to_date('02-01-2000', 'MM-DD-YYYY') start_dt, to_date('12-01-2000', 'MM-DD-YYYY') end_dt from dual union all
   select 'A' grp, 3 id, to_date('03-01-2000', 'MM-DD-YYYY') start_dt, to_date('12-10-2000', 'MM-DD-YYYY') end_dt from dual union all
   select 'A' grp, 4 id, to_date('07-01-2000', 'MM-DD-YYYY') start_dt, to_date('01-10-2001', 'MM-DD-YYYY') end_dt from dual union all
   select 'A' grp, 5 id, to_date('01-01-2000', 'MM-DD-YYYY') start_dt, to_date('01-01-2001', 'MM-DD-YYYY') end_dt from dual union all
   select 'A' grp, 6 id ,to_date('12-25-1999', 'MM-DD-YYYY') start_dt, to_date('01-05-2001', 'MM-DD-YYYY') end_dt from dual union all
   select 'A' grp, 7 id, to_date('02-01-2001', 'MM-DD-YYYY') start_dt, to_date('02-01-2001', 'MM-DD-YYYY') end_dt from dual
)
select
   grp,
   id,
   start_dt,
   end_dt,
   last_start_dt,
   last_end_dt
from
(
   select
      lag(start_dt)   over (partition by grp order by start_dt asc)  as last_start_dt,
      lag(end_dt)     over (partition by grp order by start_dt asc)  as last_end_dt,
      grp,
      id,
      start_dt,
      end_dt
   from
      t
)
where last_start_dt is null
or
not
(
         start_dt  between last_start_dt and last_end_dt
   and   end_dt    between last_start_dt and last_end_dt
)
order by start_dt asc;

G                 ID START_DT             END_DT               LAST_START_DT        LAST_END_DT
- ------------------ -------------------- -------------------- -------------------- --------------------
A                  6 25-DEC-1999 12 00:00 05-JAN-2001 12 00:00
A                  3 01-MAR-2000 12 00:00 10-DEC-2000 12 00:00 01-FEB-2000 12 00:00 01-DEC-2000 12 00:00
A                  4 01-JUL-2000 12 00:00 10-JAN-2001 12 00:00 01-MAR-2000 12 00:00 10-DEC-2000 12 00:00
A                  7 01-FEB-2001 12 00:00 01-FEB-2001 12 00:00 01-JUL-2000 12 00:00 10-JAN-2001 12 00:00

4 rows selected.

Tags: Database

Similar Questions

  • How can I get rid of several clear green empty frames in the video that I just imported to iMovie?

    How can I get rid of several frames white green clear in the video that I just imported to iMovie (9.0.4)?

    I can not just delete them because this would create a rupture in the audio (I need) that will

    along these blank frames. What 'stretching' the last good image while keeping the audio?

    Thank you for all the ideas, your time and patience. I am new to editing.

    W.W.

    Have you tried to add a freeze frame to the position of the last good image?

    Place the cursor in the timeline panel on the frame that you want to extend, and then ctrl-click, select 'add a free framework '. Adjust the handles to resize the fame of gel.

    How can I get rid of several frames white green clear in the video that I just imported to iMovie (9.0.4)?

    You use iMovie 9.0.4 or the imported movie created in iMovie 9.0.4? I don't know what version you are currently using.

  • I can not get rid of all that has taken over my computer...

    I can't get rid of all that has taken over my computer. It turned off firewall and Security Essentials. He removed my links to the areas to help MS and redirects me to some diagnostic site. I ran candy, but that did not help. Can I remove everything from hard drive and reinstall windows? that will make everything disappear?

    Hello
    If Gerry's suggestions do not work, try according to the steps described in this virus/malware removal guide: http://www.selectrealsecurity.com/malware-removal-guide
    It contains instructions which will remove most malware infections. If you have any questions, just ask me. I hope this helps you.
    Brian
  • How can I get rid of all that have hijacked my Firefox home page and replaced by a Bank of America login page?

    How can I get rid of all that have hijacked my homepage in Firefox 12 and replaced by a login page "Bank of America"? I have reset my home page in Options, but it does not help. I suspect that there is an entry of thugs in my Windows Vista registry. I tried to get rid of it with several antivirus programs, including MS Security Essentials, Avast, Spyware Doctor and Malwarebytes, but none removed the offending attacker. Help would be appreciated.

    See the likely solution the How to fix preferences that will not save help article, especially the part on the file user.js in your profile folder!

  • Thank you, Ned.   I got it to where the program opens behind the Welcome screen.  I would like to get rid of have that arise every time.  This isn't in CS5 - but at least I get the program!

    Thank you, Ned.   I got it to where the program opens behind the Welcome screen.  I would like to get rid of have that arise every time.  This isn't in CS5 - but at least I get the program!

    I have no familiarity with the program to be able to tell what to do.  If it's like other Adobe software, there should be a setting in preferences (assuming that there is an option) that allows you to dictate how the programs opens.

    In the software that I use the most, for example, if you select Edit-> preferences, the Panel that opens has what see you below where you can choose what the program has when it is launched...

  • I was just diversion & just trying to get rid of unwanted guests, I came back to the control panel & it management logo had been changed to a small page 'help '.

    XP, 32, quad, walk, I've just been diverted while trying to get rid of unwanted guests, I came back to the control panel & it management logo had changed it was changed to a page, if that's how describe you you can see I need to learn a little more about computers right! anyway & when you right click it there came a page white, but before, I was trying to get rid of those comments, there were about 5 I know where they come from bittorrent, I had to install more than one week & then I am devoured alive I had to get my tech to reformat, but these things were hidden somewhere? because I found traces of bittorrent on the computer, I give up! Please can someone! help this old man! gazza.

    Hi gazza.

    Scan your computer for malware and try to remove it.

    You can use the Microsoft Safety Scanner to do the same.

    Note: The data files that are infected must be cleaned only by removing the file completely, which means that there is a risk of data loss.

    Unfortunately, when a system is infected the best way to ensure that everything has been deleted is to perform a clean installation.

  • I can't download and install updates to Windows or games on the internet. I get an error saying that I am not on the internet.

    I can't download and install windows update or games on the internet, I get an error saying that I am not on the internet, when I help

    Trinity

    Hello

    1. what operating system do you use?

    2 did you change on your computer?

    3. what version of Internet Explore do you use?

    Method 1:

    If you are using windows 7, I suggest you check in SafeMode with network.

    Advanced, including safe mode startup options

    http://Windows.Microsoft.com/en-us/Windows7/advanced-startup-options-including-safe-mode

    Method 2:

    I suggest you of due to windows update, please see the link.

    Problems with installing updates

    http://Windows.Microsoft.com/en-us/Windows7/troubleshoot-problems-with-installing-updates

    Method 3:

    I also suggest you perform the clean boot and check.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    http://support.Microsoft.com/kb/929135

    Note: After a repair, be sure to set the computer to start as usual as mentioned in step 7 in the above article.

    See also:

    Windows wireless and wired network connection problems

    http://Windows.Microsoft.com/en-us/Windows/help/wired-and-wireless-network-connection-problems-in-Windows

    Why can't I connect to the Internet?

    http://Windows.Microsoft.com/en-us/Windows7/why-can-t-I-connect-to-the-Internet

  • Your smart phone BlackBerry Smartphones does not have system requirements that are needed to support the BB App World

    Hello

    My latest lamp died with a JVM. I just replaced today and I want to retrieve my downloaded applications. After I restored the device of BlackBerry Desktop, any of my downloaded apps are there. I have a brand new 9860, together running 7.1.  I run the App World. He told me to upgrade. When I followed the upgrades of the screen, I get an error message: notice: sorry your device does not meet the system requirements that are needed to support the BB App World. I have a brand new phone has so first question... I can update App World on Wi - FI. or should I do my first phone company data Plan? I've been running my old phone without data plan but enjoying use BBM and cell phone. Not happy.

    Yes, hopefully soon... I know that the right people are aware of the "incorrect" error message

  • When I opened my project and it is unable to locate the files. I find the files that are 'missing' and open the project.

    Hi im quite new for first pro and I'm having a problem when I opened my project and it is unable to locate the files. I find the files that are 'missing' and open the project. Everytime I open the project everything I see is all that media have these red, pink, blue, green, yellow lines, where pictures should be. And there is also the title of my pictures in the upper left corner. No one knows what it is and how I could fix this?

    [title published by mod]

    [Please do not double post, deleted the other]

    Right-click on the images in the project window: recharge or replace it.

  • How can I get rid of those annoying banners just below of the search window?

    How can I get rid of those annoying banners just below of the search window?

    Change your home page to a non-firefox one. If you want google as home page, follow these steps:

    1. Go to google.com
    2. Click on the Firefox button, go to Options | Options | In general.
    3. Make sure it says 'show my homepage' in the drop down at the top and then click on the button called "use current Pages".

    I don't see what Mozilla strives to accomplish by posting this childish junk.

  • I noticed that many of my updates there is 2 times. The same exact. Can I safely delete those that are lined and exactly the same thing? Seems I don't need the same exact 2 and 3 updates times.__Thanks__Michael

    I noticed that many of my updates of widows is 2 times. The exact same ones. I can safly remove those that are lined and exactly the same thing? Seems like I don't need at the same time exact windows updates 2 and 3.
    Here's what are installed now that confuses me.
    Running vista Home premium
    version 6.0.6002 Service Pack 2 Build 6002
    PC x 64
    Intel Core 2 Duo CPU T5550 1.83 GHz, 1833 MHz, 2 Lossnay, 2 Log
    4.00 GB
    Microsoft Silverlight
    These files were add and remove.
    Update for Microsoft Visual C++ 2005 ALT kb973923 - x 6...
    Update for Microsoft Visual C++ 2005 ALT kb973923 - x 8...
    Microsoft Visual C++ 2005 Redistributable
    Microsoft Visual C++ 2005 Redistributable
    Update for Microsoft Visual C++ 2005 ALT kb973924 - x 8...
    Microsoft Visual C++ 2005 Redistributable - x 86 9.0.2...
    Microsoft Visual C++ Run Time Setup Lib
    Would it not be better to uninstall all these and start from scratch with Silverlight?
    Or!
    To uninstall only some?
    Very confused about this.
    Some tips would help a lot.
    I think I posted all the files that were related to this as well as information on the system.
    Thank you
    Member of 1care Michael B.

    Mike

    CF. http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/b9132e0a-31ad-4f3c-af7d-8719972453ab

    Visit the Microsoft Solution Center and antivirus security for resources and tools to keep your PC safe and healthy. If you have problems with the installation of the update itself, visit the Microsoft Update Support for resources and tools to keep your PC updated with the latest updates.

    ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • Download Itunes on my laptop just before, it starts to install, I get a message saying that windows Explorer stops because the prevention of execution of data has stopped installation

    original title: Itunes and DEP

    While downloading Itunes on my laptop right before you start to install, I get a message saying that windows Explorer stops because the prevention of execution of data has stopped installation.  Is there any solution for this?  I'd like to install itunes on my laptop.

    Hi Steve681229,

    Thank you for using the Microsoft Answers forum.  Here's what worked for someone else.  Thanks Kevin

    Hi thrivenformore,

    Please use the forum for Support of Vista,

    You could try to add iTunes to the DEP exception list.  However, this behavior is not normal.  Go to the support forum of Apple for iTunes for Windows, search on DEP.  There should be a thread "How can I turn off DEP for iTunes?" or it Prevet planting iTunes? "which provide troubleshooting steps you might want to try before adding it to the list of exceptions."

    How to add the program to the DEP exception list:

    1. Press Start, right click on computer and select Properties.
    2. in the window that appears, click Advanced (on the left panel) system settings.
    3. in the first box that says Performance, click on the settings button.
    4. in the window that opens, click the Data Execution Prevention tab at the top.
    5. There should be a box of exceptions in the middle of this window. Click the Add button and navigate to the C: drive, then Program Files, then the iTunes folder, and then choose the iTunes exe.
    6. Add the exception, and then click OK in the window of the DEP.

    Hope this helps, Kevin
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

    Thank you for using answers Forum. Please let us know how it works.

    Joseph
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • A way to show items that are not used in the sequence

    Hello world

    is there a way to display items that are not used in the sequence.

    in order not to forget the "rushes" in the Assembly?

    my best,

    Turn on the use Audio and video columns in the sandbox and then sort by those.

  • How to remove special characters that are not available in the key board

    Hi all
    How to remove special characters that are not available in the key board.
    select '106    ©      500049' str from dual;
    
    After removal of the special symbols ( not only copy right, it can be any special symbol other than key board symbols), I want to add a single space between two number.
    
    Output should be like:
    Str
    106 500049
    Thank you for your help in advance.
    select
     '106    © ® (k)      500049' str
    ,regexp_replace('106    © ® (k)     500049', '[^[:digit:]]+', ' ') r
    from dual
    
  • can I install PES 11 on two laptops that are not used in the same place?

    Can I install PES 11 on two laptops that are not used in the same place or at the same time?

    Yes, your license entitles you to two simultaneous activations.

Maybe you are looking for

  • visited links not changing color using the latest Firefox and windows 10

    running windows 10 and the latest firefox freshly downloaded and installed.have checked the visited_links is enabled, and I'm not running in private modeI know it's only a problem of firefox like links change color using other browsers

  • How to put in the empty new tab page

    I'm new to firefox and a lot of learning to take in.we a IE8 with a lot of problems so go to firefox.gets source of confusion for us sometimes we don't know much about the computers.don't know how to get the back of the browser, things we had before:

  • Connection Internet keeps falling with MacBook Pro OS 10.11.3

    Wifi works fine in our House on all of our devices until I turn on my MacBook Pro. Then the wifi said even it is connected on all my devices, but nothing will load on any device. I have to restart our modem and router. Then it will work for a few min

  • How can I reconnect to Gmail accounts after accident?

    My MacBook running el Capitan that crashed yesterday (gray screen frozen at startup). When I restarted Mail could not connect to Gmail accounts. I have read the discussions and tried everything. I have deleted the Gmail accounts and tried to restore,

  • Satellite Pro L300-1FN PSLB9E PCI/controller XP drivers Ethernet

    Hi all, I have downgraded my laptop XP Pro and downloaded the drivers concerned on the Toshiba site. I'm still waiting for Miss an Ethernet and PCI controller drivers. Someone at - it a link to the drivers for this model (Satellite Pro L300-1FN (shor