Calculate hours on a timeline, excluding the duplicated time

RDBMS 11.2.0.3

Create the table (date startdate, enddate date) work;

Insert in work values (to_date (December 16, 2015 11:45:30 ',' mm-dd-yyyy hh24:mi:ss'), to_date (16 December 2015 14:30 ',' mm-dd-yyyy hh24:mi:ss')); ))

insert into the work values (to_date (16 December 2015 12:00:30 ',' mm-dd-yyyy hh24:mi:ss'), to_date (16 December 2015 17:30 ',' mm-dd-yyyy hh24:mi:ss'));))

insert into the work values (to_date (16 December 2015 22:45:30 ',' mm-dd-yyyy hh24:mi:ss'), to_date (December 17, 2015 01:15:25 ',' dd-mm-yyyy hh24:mi:ss'));))

insert into the work values (to_date (December 17, 2015 13:45:30 ',' mm-dd-yyyy hh24:mi:ss'), to_date (December 17, 2015 20:30 ',' mm-dd-yyyy hh24:mi:ss'));))

insert into the work values (to_date (December 17, 2015 19:45:30 ',' mm-dd-yyyy hh24:mi:ss'), to_date (18 December 2015 02:30 ',' mm-dd-yyyy hh24:mi:ss'));))


STARTDATEENDDATETIME_DIFF
16/12/2015-11:45:3016/12/2015-14:3002:44:30
16/12/2015 12:00:3016/12/2015-17:3005:29:30
16/12/2015-22:45:3017/12/2015 01:15:2502:29:55
17/12/2015-13:45:3017/12/2015-20:3006:44:30
17/12/2015-19:45:3018/12/2015-02:3006:44:30

I calculate the amount of hours spent on the timeline excluding duplicate time.

The timeline is the range of first STARTDATE ( 16/12/2015-11:45:30) until the last ENDDATE (18/12/2015-02:30) I want to calculate hours excluding duplicated between this interval hours.

For example.

First row:

Of 16/12/2015-11:45:30 up to the 16/12/2015 14:30 I have the diff from 02:44:30

Second row:

Of 16/12/2015 12:00:30 until 16/12/2015-17:30 I have the diff of 05:29:30, but the value of start_time (16/12/2015 12:00:30) is duplicated because was already on the range calculated level 1, so I have to remove it.  Then the correct range of second row is of 16/12/2015 14:30 to 17:30 16/12/2015 correct time is 03:00.


I need the make and to end computed in time past on vary from first STARTDATE and ENDDATE last, excluding the duplicated times.

Any help is welcome.

Hello

Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!

Don't forget to post the exact results you want from these data.  For example:

GRP_STARTDATE GRP_ENDDATE HOURS

------------------- ------------------- ------

16/12/2015 11:45:30 16/12/2015 17:30 5.7417

2015/12/16 22:45:30 17/12/2015 01:15:25 2.4986

2015/12/17 13:45:30 12/18/2015 02:30 12.742

If this is what you want, here's a way to get it:

WITH got_new_grp AS

(

SELECT startdate, enddate

CASE

WHEN startdate > MAX (enddate) over (ORDER BY startdate, ROWID

ROWS BETWEEN UNBOUNDED PRECEDING

AND 1 PRECEDING

)

THEN 1

END AS new_grp

Work

-WHERE--if necessary

)

got_grp AS

(

SELECT startdate, enddate

COUNT (new_grp) OVER (ORDER BY startdate) AS grp

OF got_new_grp

)

SELECT MIN (startdate) AS grp_startdate

MAX (enddate) AS grp_enddate

24 * (MAX (enddate)

-MIN (startdate)

), Hours

OF got_grp

GROUP BY grp

ORDER BY grp

;

It is, fundamentally, a problem with GROUP BY. We need the difference between the (enddate) MAX and MIN (startdate) in each group of overlapping lines.

The tricky part is to identify groups of lines that overlap (grp in the above query).  We can identify a new group to the beginning (new_grp) by checking if startdate of a line is greater than all the previous lines enddate (where 'previous' means in order by startdate).  To identify what group each line belongs to, we can count how many groups have already begun.

Tags: Database

Similar Questions

  • ? Flash CS4, it is possible to adjust the length of several timelines at the same time?

    Hello

    I'm using Flash CS4. Is it possible to adjust the length of several timelines at the same time? I do an animation of the leaves that fall from the tree. The only leaves 17 separate calendars on separate layers and each has its own guide layer.

    If I had the opportunity to select all the chronologies set and adjust all their respective time start and end at the same time even, compared to the other, but also separately, life would be so much easier!

    Of course I can do timeline timeline, no problem, but I can't adjust the length in addition to a scenario at a time. (no pun intended)

    Even when I select more than one timeline, the double arrow only adjusts the length of a timeline. Even each layer guide must be set separately. I understand the benefit of this, but, timing tests and make adjustments would be so much easier and go a lot faster if I could select and drag several lengths of timeline at the same time.

    Is it possible to do this?

    I am new to Flash, thank you for your patience with me!

    SabelV

    You are welcome.

  • When I use the razor blade tool, is it possible to you cut through ALL the tracks in the timeline at the same time?

    Hello

    In Final Cut Pro 7, there is a way to have the tool bracket razor blade across ALL the tracks in the timeline (sequence) both. First, I see no way to do this. I'll have to cut each piece one at a time. What Miss me?

    Hi Paul,.

    Select the Razor tool, just hold down the SHIFT key and left click the mouse where you want to make a cut.

    Vinay

  • Cannot select multiple clips on the timeline at the same time...?

    Hello

    I have a new MacBook Pro running OS X 10.10. I'm running the first Pro V. 8.1

    When I click on a clip on the timeline, and then press SHIFT and click on something else in the meantime program to select all the clips in the meantime... it doesn't.

    Known issue? I am ex-FCP7 and I want to really make my go-to new Premier Pro, but not be able to select several clips is problematic.

    See you soon

    MD

    I think it's just how it works, not sure of any option to change it. It discusses the shift as ctrl/cmd, very strange.  You can use the mouse to drag a box on the clamps. There are also track select Tools from the toolbar.

  • How to calculate the hours between two dates by the numbers

    If I update 09:00 start time 17:00 end time of shift in C3 and B3, how to use a D3 formula to calculate the number of hours between the two?  Then I can just copy down the lines for nth years...

    It is a spreadsheet of the part-time staff payroll.

    I'm sure that a lot of people out there have done that.

    Help, please.

    Thank you.

    Eddie

    What program of worksheet that you are using? Since you have a newer iMac running El Capitan, I can safely assume that you use NOT AppleWorks, which is a Power PC application that can run on any OS newer than the snow leopard, OS X 10.6.8.

    If you use numbers, try to repost your question in numbers for Mac forum. If you use Microsoft Excel, try posting in the Microsoft forums. LibreOffice also has community support.

  • Calculate the elapsed time between the horodateurs log Table

    Hello

    I'm looking for some codes SQL allows to calculate the elapsed time between the timestamps in a log table.  The log table has some STOP-START operations.

    I just want to calculate the elapsed time between the START and PAUSE of Transactions, as well as START and EXECUTE transactions.

    So, in the example below, the time spent must be:

    START 09:15 break 09:20 (5 Minutes)
    START 09:30 to 09:45 (15 Minutes) FULL

    Total elapsed time for LOG_ID 1234 should be 20 minutes.  This excludes the 09:20 at 09:30 BREAK at the START time.

    LOG_ID

    SEQ_NUM

    LOG_TYPE_CD

    CRE_DTTM

    1234

    1

    BEGINNING

    09-15 - 2013:09:15:00

    1234

    2

    BREAK

    09-15 - 2013:09:20:00

    1234

    3

    BEGINNING

    09-15 - 2013:09:30:00

    1234

    4

    ALL THE

    09-15 - 2013:09:45:00

    Any suggestions?

    Thanks for your time

    -DT

    Hello

    Thanks for posting the CREATE TABLE and INSERT.  be sure to post the results desired from these data.

    user13071913 wrote:

    Hi thanks for the help...

    The date is a true timestamp.  ...

    Here's a sample of CREATE TABLE and a few inserts.  3 ID transaction, each with a series of journal entries.

    CREATE TABLE 'LOG_TABLE_X '.

    (SELECT 'ID' CHAR (14 BYTES) NOT NULL,)

    ACTIVATE THE "LOG_TYPE_FLG" TANK (4 BYTES) NOT NULL,

    ALLOW "LOG_DTTM" DATE NOT NULL

    );

    ...

    I'm so confused.  Is log_dttm a TIMESTAMP, you said in the story, or is it a DATE, as you say in the CREATE TABLE statement, or is it a VARCHAR2 as Thur INSERT statements?  I'll assume it's a DATE.

    I left out an important step yesterday.  The computation of the last_start, we need to use a CASE statement so that we record only the time of events STRT.

    Here's the revised query:

    WITH got_last_start AS

    (

    SELECT id, log_type_flg, log_dttm

    LAST_VALUE (CASE

    WHEN log_type_flg = "STRT".

    THEN log_dttm

    END

    IGNORES NULL VALUES

    ) OVER (PARTITION BY id - can - be

    ORDER BY log_dttm

    ) AS last_start

    OF log_table_x

    )

    SELECT id, log_type_flg, log_dttm

    , (log_dttm - last_start) * 24 * 60 elapsed

    , SUM (log_dttm - last_start) OVER (PARTITION BY ID.

    ORDER BY log_dttm

    ) * 24 * 60 AS total_elapsed

    OF got_last_start

    WHERE log_type_flg IN ("CMPT", "PAUS")

    ORDER BY id, log_dttm

    ;

    Output of your sample data:

    ID LOG_ ELAPSED TOTAL_ELAPSED LOG_DTTM

    -------------- ---- ------------------- -------- -------------

    1111 PAUS 09-26 - 2013:09:09:58.17.17

    1111 CMPT 09-26 - 2013:10:09:58 1.00.83

    2222 CMPT 09-26 - 2013:12:09:58 180.00 180.00

    3333 CMPT 09-26 - 2013:10:09:42 59.73 59.73

    In Oracle, when you subtract one DATE from another DATE, the result is the NUMBER of days between them.  In the above query, I multiplied the past columns and total_elapsed by the number of minutes per day (24 * 60), to show the time in minutes.

  • How pre-made only parts of the timeline or the selected clips?

    I move from Vegas Pro in Premiere Pro. In Las Vegas, you select a part of the timeline, and then press CTRL-B and that it makes this segment.

    First, you press on enter, but he does not pay attention to the selected clips, she makes just before the entire sequence.

    This would not be a big problem except that I'm managing projects that are long enough, with 20-30 sequences and sequences 20 or so nested in each project and I spend between about 18 different projects for a series of videos 23 or almost.

    These videos are already taxing my system resources with only a few minutes or so (referencing about 80 to 120 GB of the source footage), but my desktop computer is a little weak.

    The problem is that when I have pre-made a nested sequence and bring on the main timeline, I pre-rendered it * again * after the next series of adjustments (ie the color correction, transitions, etc). So, I have to do AGAIN when I copy it to another scenario for a similar project.

    Each time, it may take as long as 15 or 20 minutes (my graphics card is a nVidia GTX 560 Ti, there CUDA, but prem does not support a reason any).

    When my script main glitched out, forcing me to divide it into different projects, it took me almost 4 hours just to copy things up with another 20 minutes to load the file glitched.

    Then I had to go and pre-made everything new to work my edits in place.

    Even if everything is properly set up to 90%, I still have to wait for the entire sequence finish the pre-rendered.

    As above, in Vegas Pro, I simply select a part of the timeline and the sticks of pre-rendered to this area.

    I saw an article that said that you might create on edge and use it for rendering, but it doesn't seem to be something CS6.

    I heard that Adobe was trying to maintain CS6 as a parallel to CC thing. Surely I don't have to move to a subscription of 600 $par year just so that I can pre-made parts of the script as a low-end competitor program has had something like 5 years...?

    What Miss me? There must be a way to do it simply.

    You should uncheck the workspace toolbar in the Menu of the Panel (upper right corner), the timeline.

  • How to exclude the songs, didn't like in a smart playlist

    How exclude the songs didn't like in a smart playlist.

    Note the songs that you don't like as 1 Star then add side is not 1 star smart selection criteria.

  • Apple Watch displays an hour ahead of the actual time that is displayed on the iPhone

    My Apple Watch displays the time one hour before than what is displayed in my iPhone 6 +. I tried to reset the data sync APP for watching on the phone but nothing happens at all as if I do not what it is, I tried a simple reset to the phone and watch (pressing power and home buttons until the Apple logo appears) but that has not solved the case either manually set the time on the phone hoping the watch itself would be up, synchronize with the new time got nowhere either. I waited a few days hoping that he would set himself the way he went before this time, but nothing.

    Please advise.

    Hello

    If you are located in Egypt, note that some other users have reported experiencing the same problem.

    It can help to update your iPhone to the latest version of the software, (although instead, you see the same question then applies also to your iPhone):

    You may need to contact your mobile operator for assistance.

    You can also make Apple to know that you are experiencing the problem:

    More information:
    Get help with the date and time on your iPhone, iPad and iPod touch - Apple Support

  • Can cut is no longer clips of media to drag in the timeline of the movie

    Once I have download media, and I create a movie in iMovie, I am no longer able to highlight the small clips of media uploaded to slide on the timeline of the movie.  I did this for years with ease, but now when I upload media (let's say it's a 90 minute video), when I touch the clip it highlights the whole thing instead of letting me choose that it contains.  Any help would be great!

    Yes, there was a change in the last update to iMovie.  The default is now to choose the full clip.  To select a part of a clip in an event that you have pressed the 'r' key while you move the cursor over the area you want to select.  An alternative is to position the cursor at the beginning of the selection and press 'i' and then place the cursor at the end of the selection and press 'o'.

    Geoff.

  • I have the latest version of FF and the latest version of Roboform... everything has worked perfectly until an hour ago... now the Robofrom toolbar will not work... its

    I have the latest version of FF and the latest version of Roboform... everything has worked perfectly until an hour ago... now the Robofrom toolbar will not work... says not compatible... it is activated in Add ons... nothing has been put to day or changedf suddenly just no toolbar and it will not tie

    RoboForm will probably have an update for Firefox 30 when Firefox 30 is actually out, if not sooner. No need to turn off the automatic updates now.

  • Why my time to send an hour ahead of the actual time and how to reset it?

    When I send an e-mail message, the timestamp is an hour before the actual time.

    How to reset the time?

    You need to reset the time zone of your email account by going to the settings... option or you must be selected your country, city and code postal correctlly... & that is the question of the email provider... For more information I suggest you the e-mail provider is better, th...
    You can check in comparison with any other provider of messaging (e.g. Gmail or yahoo mail)... If your email provider is not helpful, you can always write it here...

  • I have worked for an hour on a treadmill and the ring of read activity 7 min. In the application of the workout, I chose the domestic market. Do I have to have my phone in my pocket for it from the activity of the hour on the ring

    I have worked for an hour on a treadmill and the ring of read activity 7 min. In the application of the workout, I chose the domestic market. Do I have to have my phone in my pocket for it from the activity of the hour on the ring?

    If you wore the watch - (as your signature "Look" inside) then no - the phone should not be in your Pocket

    Otherwise Yes - it's the only way the phone detects your movements

  • How to calculate the execution time of a SCTL in FPGA VI?

    Hello

    Can someone guide me that how to calculate the execution time of a SCTL for an iteration in the FPGA VI?

    Thank you and best regards,

    Rashid

    Hello r,.

    A SCTL will always run in a beat the clock it has been linked to.  So, if you use a 40 MHz clock, this loop will run in 25 ns.  If the code cannot complete in that, or if it requires two graduations of the watch to do the calculation, your code does not compile, then you have the guarantee that this will always be how long it takes this piece of code to run.

  • Recording of data every hour, labview stops responding when the program stopped

    Hello. I'm doing a labview program to read the data and recording to a PDM file every hour for as long as it runs. First of all, I wanted to test it on every 15 minutes to work the bugs how. I made the attached VI and simulated data. It works fine but when I press the stop button to stop the program, the mouse cursor becomes the "wait cursor" and it remains like that until the program says "(ne répond pas) ' and then it crashes." Needless to say that the data is not recorded or corrupt. Do not do this with shorter time intervals (say, record data every 15 seconds). Is the long time period why its happening? Is there a better way to address the issue? Thank you!


Maybe you are looking for

  • bios dv6119us

    The bios of my dv6119us has a very limited menu.  I need to be able to access the battery and plugged in option.  Any ideas?

  • Uninstall the Pavilion d4650e Xp

    On HP Pavilion d4640e of operating system XP Pro Sp3. need to uninstall reinstall but no disc, no internet access and no HP tools or PC help & tools. To make it worse, I can not F10 to work. I just get a screen back (no command sends me options to co

  • No sound in media center

    It happened recently.  I am getting sound in WMP and QuickTime player but not Windows Media Center.  It will not read video files or live tv.  He plays good music.  I tried to configure the speakers, but that did not work. Anyone knows what is the ca

  • This copy of Windows is not genuine after updating Windows 10 and return to Windows 7 Ultimate

    When I've updated to windows 10 using the windows icon free 10 in the corner, it didn't appeal to me, so I used the button restore to go back to windows 7. After he turned back, a saying watermark "Windows 7 Build 7601 this copy of windows is not gen

  • What is the new .desktopthemepack file extension?

    When I tried to download a desktop theme, I discovered that the uploaded file has an extension that does not recognize the Windows 7. This will open new files in the theme pack format?