Find missing at time interval in SQL

All the

Need help with SQL to find the missing time interval.

My query returns data as shown below

Data1

StartTime EndTime column
=======   =======   =======

T2 09:00 18:00
T3 20:00 23:00

Data2

StartTime EndTime column
=======   =======   =======

T1 15:00 20:00
T3 20:00 07:00

Take above output, I want to find time is not on my data within 24 hours of the first StartTime on each set of data.

Example: Data1

First StartTime: 09:00 (registration T2)

Add 24 hours, which will be updated 21:00.

Result to get missing scheduled interval for Data1
18:00 - 20:00

23:00-09:00 (next day)

For expected result of data2

07:00-15:00 the next day

The basic version: 11g

Someone at - he met to calculate the missing time interval? Can I use PL/SQL for this as a function of pipeline?

Any help/directions/references that I greatly appreciate.

Thanks in advance.

Edward

One way to find missing intervals:


alter session set nls_date_format = 'DD-Mon-YYYY HH24:MI:SS';
with data as
(
  select to_date('28-Jun-2013 09:00', 'DD-Mon-YYYY HH24:MI') start_time, to_date('28-Jun-2013 18:00', 'DD-Mon-YYYY HH24:MI') end_time from dual union all
  select to_date('28-Jun-2013 20:00', 'DD-Mon-YYYY HH24:MI') start_time, to_date('28-Jun-2013 23:00', 'DD-Mon-YYYY HH24:MI') end_time from dual
)
select start_time, end_time,
       case when lead(to_char(start_time, 'HH24'), 1, (select min(to_char(start_time, 'HH24')) from data)) over (order by to_char(start_time, 'HH24')) not between to_char(start_time, 'HH24') and to_char(end_time, 'HH24')
              then to_char(end_time, 'HH24:MI') || ' - ' || lead(to_char(start_time, 'HH24:MI'), 1, (select min(to_char(start_time, 'HH24:MI')) from data)) over (order by to_char(start_time, 'HH24:MI'))
            else
              null
       end period
  from data

START_TIME                END_TIME                  PERIOD
------------------------- ------------------------- -------------
28-Jun-2013 09:00:00      28-Jun-2013 18:00:00      18:00 - 20:00
28-Jun-2013 20:00:00      28-Jun-2013 23:00:00      23:00 - 09:00

Time information should not be stored in additional fields Varchar, if you have the Date column. You can use Date fields that store the Date and time together.

Another way to approach this problem is to connect by Clause, or model. Use the search feature to find solutions using these methods too. However, in my opinion, this method is the fastest of all.

Tags: Database

Similar Questions

  • How can I find missing backups time capsule?

    Installation of El Capitan in September caused my incoming mail to stop after a certain point, although he showed millions of so-called items waiting to be downloaded. After many attempts of troubleshooting, I went with my last resort for fitness and do a clean install of El Capitan.

    When I went to my Time Capsule to restore my documents and applications showed none of my previous backups using the Star Wars. There are available dates in the timeline view, and the time Capsule shows my oldest as backup being December 1, 2015 after I ran the backup check, but I don't see anything beyond yesterday.

    Backups must be present on the Time Capsule, because it shows "tuberculosis 1.14 2 TB available." My sparsebundle (only 13.2 MB) indicated no mountable file system when I double click on it. It also has . tmp.sparsebundle as the extension. There is no other sparsebundle showing.

    I was looking for answers online and this forum and have yet to find a resolution. My first care in disk utility failed after a few hours, then immediately when I tried again. Any suggestions? Is it useful to fitness again? I did not choose the time Capsule to restore initially. I wanted to see if the mail would work before putting the time restore everything.

    Thank you

    Linda

    MacBook Pro (early 2011) El Capitan 10.11.3

    Time Machine, please press the shift-command-C key combination. The windshield will show the mounted volumes. All snapshots should now be accessible. Select the one you want and search for files to restore.

    If you need to restore from a backup of the hidden user library folder, first select a snapshot, and then press shift-command-G. A go to the folder dialog box opens. In this document, you enter the path to the folder. The dialog box will help you by automatically filling parts of the path when you start typing.

    The path starts with the slash character ("/"). Enter that. The rest of the parts is separated by slashes.

    The next part is the date and time of the current snapshot. Enter a '2', and the rest of the date should be filled in automatically. Press the right arrow key to access the end of the path. Enter a slash to start the next game.

    Next is the volume name (usually "Macintosh HD" unless you assigned a different name.) Start typing, then jump to the end and enter a slash.

    The next part is 'Users', followed by a slash.

    Then is your short user name. It is also the name of your home folder, which is represented by an icon of the House in the sidebar of a Finder window.

    Finally, enter "Library", and then press return. You should now be in the library folder. From there, you can move like in the Finder. You can also select another snapshot of the same folder.

  • The shortcomings of SQL to find missing persons

    Hi gurus,

    I have a simple SQL question on how to find the gaps. I have a Table: GLHDR_M with ACUTE flange as key field with an ID of account from 'A1000001' to 'A3999999', but with gaps inbetween. I want to reassign the missing IDS to those newly created. How can I find the missing ID with a simple SQL statement?

    Thank you

    Otherwise, you can simply add the condition "AND PRIOR DBMS_RANDOM. VALUE don't IS NOT NULL' with the connect by clause

    SELECT 'A ' | LPAD (TO_NUMBER (LTrim (Replace ('A0904000', 'A'), '0')) +(rowNum-1), 7, '0') accide

    OF THE DOUBLE

    CONNECT BY LEVEL<= to_number(ltrim(replace('a0904999','a'),'0'))-to_number(ltrim(replace('a0904000','a'),'0'))="" +="">

    AND PRIOR DBMS_RANDOM. VALUE IS NOT NULL

    LESS

    SELECT acid glhdr_m acid WHERE BETWEEN 'A0904000' AND 'A0904999 ';

    I don't have a 9i environment to test this. Then you can try it, and if you get the error, you can try with the function table in pipeline I gave already.

  • Find missing files does not work - what don't get me?

    I have had my photos stored on an external hard drive and upgraded to a bigger external drive. My husband has copied the files to the new drive. Now I can't access photos on the drive. I followed the steps to update the location of the pictures, but it does not work. I tried "find lack of pictures" and that does not work either. I follow the steps, but nothing happens.

    What I am doing wrong? I suspect, I'm missing a simple step, but I tried several times with both drives. I restarted LR. I restarted the computer. Nothing makes no difference.

    Thanks for any help or someone can give advice.

    Hi nannetter,

    Please connect the new external drive that contains all of the images, now open Lightroom and on the Library tab, update the location of the folder.

    See the link below.

    How to find missing photos in Photoshop Lightroom

    Note: Please make sure that copy you all images in the structure of the last hard drive to the new.

    Kind regards

    Mohit

  • Update/Find missing * drive * query

    Good day to you all

    I'm looking for a way to apply the function "Find Missing folder... "the real disk. Essentially using the drive letter that the 'file' parent synchronize all subfolders and update all the paths of the image.

    The scenario;

    I had all my photos on a local disk "W:".

    They are now all on a network drive - we'll call this \\NAS\Photos (where photos are the name of the share on the network drive)

    I can manually cross records 'disappeared' w: in the left pane of the library and 'Find Missing files..' at the same time. This method works.

    However, I have about 100 cases so it is very time consuming.

    The folder structure is exactly the same thing, what I would do is update the path in the CAR so I can keep all of your changes to LR.

    Any ideas?

    TIA

    So what exactly are you doing... are you trying to recreate a link to one of the missing files to the folder parent on the NAS Server? What is the parent folder showing in the files Panel in the Lightroom library module? If this is the case, it is the folder you need to re-edit the equivalent parent on the NAS.

    If, however, the parent folder is NOT displayed in the files Panel, then right-click on any of the 'missing' files and select "Show Parent Folder"... which should add the folder parent in the folders Panel, so that you can then republish with a single command 'Find the missing folder' (the ability to display a parent folder for missing files is a new feature in LR4 you could not do in earlier versions).

  • How to find how many times a certain data is repeated in a character field

    Hello
    I am user of Oracle 9i and a newbie to SQL.

    How to find how many times a certain data is repeated in a field in a table of character?

    for example.

    DEPT_NAME
    ------------------------------------
    Homeopathy
    Medicine
    Homeopathy
    Erices
    Homeopathy
    Surgery
    Urology
    Cardiology
    Homeopathy
    Opthamology

    DEPT_NAME here is an area of character and I want to know how many times _ 'Homeopathy' is repeated in the field "DEPT_NAME."

    [email protected] wrote:
    Hello
    I am user of Oracle 9i and a newbie to SQL.

    How to find how many times a certain data is repeated in a field in a table of character?

    for example.

    DEPT_NAME
    ------------------------------------
    Homeopathy
    Medicine
    Homeopathy
    Erices
    Homeopathy
    Surgery
    Urology
    Cardiology
    Homeopathy
    Opthamology

    DEPT_NAME here is an area of character and I want to know how many times _ 'Homeopathy' is repeated in the field "DEPT_NAME."

    You can use the COUNT aggregate function.

    SELECT count(*) FROM  WHERE dept_name = 'Homeopathy'
    
  • My computer disconnects me way too fast. How to change this time interval?

    It seems that if I turn my back for a minute, my HP desktop computer disconnects me and I have to re - enter the password.  A significant pain in the neck... How can I adjust this time interval?

    Hello

    Open windows control panel, open personalization, click on the link on the bottom right and in the next window, screen saver set time "Wait" to a more acceptable figure and Remove the tick in the box next to "in curriculum vitae, the logon screen.  Click on apply, then Ok to save the setting.

    Kind regards

    DP - K

  • Time interval in the output file is different from the sampling frequency

    Hello

    I'm a load at 1000 Hz. cell sampling I send information to the VI "write to a measurement file. When I opened the .tdms in excel, the time interval between samples is 0,00062 seconds instead of 0.001 seconds. Is it possible to change the time interval seconds a.001?

    Kind regards

    Johan Hendrikse

    It has sampling frequencies different - he has simply not an infinite number of them. I should have been a little more clear as to what I wanted. Have you read the specifications? Sampling frequencies are defined as 50 000 / n where n is an integer between 1 and 31. When you specify a rate, the driver will put it to the nearest that the material support. A little arithmetic shows that 50000/31.00062. How do you rate? Will this work with a DAQ Assistant?

  • Missing entry time.dll C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\DLCC: RunDLLEntry

    whenever I start my computer, this massage is coming:

    Missing entry time.dll C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\DLCC: RunDLLEntry

    What is this for?  Can I do anything about it?

    Thank you

    Roya

    What make and model of printer you have?

    It could be virus/malware related butI I think this may just be caused by the drivers of your printer,

    Make sure your machine is pest free, run a MalwareBytes scan on your computer: http://www.malwarebytes.org/

    If the machine comes out clean reinstall your printer drivers.

    John

  • How do you find the last time that an address older Windows Live Hotmail has been used if you don't remember the password?

    How do you find the last time an old hotmail address was used... especially if you can't remember the exact password?

    original title: old hotmail address

    How do you find the last time an old hotmail address was used... especially if you can't remember the exact password?

    Good enough if you can't on the account and you can't prove it is yours in order to regain access (via password self-service reset, etc)-then you won't know anything about the account.

  • Error blue screen "a clock interrupt was not received on a secondary prossesser in the allotted time interval.

    I get a blue screen that says that this A clock interrupt was not received on a secondary prossesser in the allotted time interval

    * original title - an interruption of clock has not received on a secondary owner in the amount of time allocated Windows stops and I get a blue screen that says this *.

    It is likely that your CPU is a failure.

    However, before replacing, try this

    1. If you are overclocking the processor, back to normal speed
    2. To avoid overheating, get a can of compressed air and dust out of your computer
    3. Go to the website of the manufacturer of the computer, download and install the latest drivers and BIOS for your model
  • Virtual Storage Manager - can't change instant planning time interval with vSphere Web Client

    Hello

    I try to activate Virtual Storage Manager schedules-model for a data store using vSphere Web Client. Everything works fine, but I can't change the time interval of planning of the snapshot. He remains at 12:00 midnight to 12:00 midnight. I can't change it manually or by dragging the bar.

    I tried with IE9, IE11, newer Chrome browsers. And with Flash versions 15 and 13-. Same mistake.

    I've added the URL of Sites you trust with weaker security settings - no help.

    Y at - it a bug or something else I can try?

    I just talked to Dell support on my problem and this is apparently a known issue with local Europe\UK.  The similarity of our problems might be useful - workaround for me was to settle the Locale\Regional from my PC, where I'm doing it in the United States.  Not the time zone or other settings, to control panel, then "Region and language", then on the first tab, 'Format' box should be set to "English (United States).  Close browsers, start again and it worked for me.

    Might be worth a try if you're not already in US format. (mine was in the United Kingdom).

  • Sorry, unable to save your movie. Find missing files or delete the unusable items in your project and then try again. "Error: 0 x 87160129" during video editing in Windows Movie Maker/Windows Live Movie Maker

    I use the same device which was used to make movies in the past with no problems. The error message is sorry, unable to save your movie. Find missing files or delete the unusable items in your project and then try again. Error: 0 x 87160129

    I've never had any problems with this before and made more than 100 movies using WLMM or WMM. Thanks for any help. Would that my camera settings? I use a Lumix.

    I just found out what the problem is freakin ' and the solution. If the inserted videos have different "video codec" then it will not work!

    Before adding videos to Movie Maker, throw in a video converter and convert them all. (Even if the original format is WMV, convert again to WMV) that will ensure the output videos have the same codec!
    This solved the problem for me, hope, it does for you too...
  • Receiving the message: a clock interrupt has not received on a secondary processor within the allotted time interval. What is the problem?

    My computer goes to blue screen and gives the message above and also said STOP: 0 X 00000101 (0 X 0000000000000031, 0 x 0000000000000000, 0XFFFFF88003163180, 0 X 00000000000000002) of physical memory on the drive of Dumping:

    First says Windows has been shut down to avoid damage.  A clock to interrupt not received on a secondary processor in the allotted time interval.

    Happens if my home screen appears and automatically plays a commercial or video file or if I try to play a video of Facebook, YouTube or my email etc.

    My computer is a Lenovo Z560.  He has done since the day that I brought home from the store.
    I should take that back when I bought first, but did not. I got this computer more than a year.

    Thank you.

    Hello

    If you received a blue error screen, or a stop code, the computer stopped abruptly to protect against data loss. A hardware device, its driver or software might have caused this error.

    Control bug 0 x 101: CLOCK_WATCHDOG_TIMEOUT-This indicates that an interruption of clock expected on a secondary processor in a multiprocessor system, has not received in the allotted interval.

    http://msdn.Microsoft.com/en-us/library/ff557211%28VS.85%29.aspx

    Important: Running chkdsk on the drive if bad sectors are found on the disk hard when chkdsk attempts to repair this area if all available on which data can be lost.

    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.

    I suggest you to download the minidump files so that the experts here can analyze the cause of the error on a blue screen.

    Try using this link to download pictures and files on SkyDrive.

    Download pictures and files:

    http://Windows.Microsoft.com/en-in/SkyDrive/add-photos-files-FAQ

    Please post back with the State of the question.

  • How to find missing values in the table?

    Hi all..

    Please help me.

    1.jpg

    For example:

    I have a. table

    in this table, I have a folder with the number 1 up to 10 serial number.

    And then, in table B, I put number between 1 and 10.

    and I use the number 1, 2, 3, 6, 8, 10.

    I want to find missing values between 1 and 10. So, can I select with query for this case?

    It's the value of query output:

    4, 5, 7, 9

    Sorry for the bad language.

    Thank you all.

    Select

    r

    Of

    (

    Select Rownum r

    Of the double

    Connect by Rownum<= (select="" serialto="" from="">

    )

    where are > = ((select serialfrom from tablea))

    less

    Select the series from tableb

Maybe you are looking for

  • dual-boot 10.8 and 10.11

    Hello people - I'm running a MBPro 2011 currently dual booting OS 10.6 and 10.8.  I use my computer professionally and need to stay in the sweet spot for a variety of programs that don't play well with the latest and great artist OS versions.  The ne

  • Create plots by programming/hide

    All, I want to programmatically set the visibility of the plots and tab control pages. The solution I came up with that was to set the visibility property nodes in a case structure and based on the value of the control, many of the plots will be visi

  • transfer to a flash drive, of files to the folder "my music"...

    Greetings friends, I am new on Vista Ultimate, and I'm confused as to how to transfer my music from a USB flash files in my music folder... Can someone help me with this problem please?  I would be very happy... Please...

  • Bad Version of Vista?

    I think I'm under 32-bit Windows Vista version when I need to run the 64-bit version. Any suggestions?

  • (Redirected) Replacement card mother Aurora R4

    Hello!  A few years ago, I bought the Alienware Aurora R4 desktop computer.  After about a year my motherboard breaks down after trying to solve the problem of noisy fan that they suffer a lot.  I bought a new X 79 LGA2011 Micro ATX Intel motherboard