Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cumulative total time per week

Geert JoostenAug 13 2019 — edited Aug 14 2019

Hi everybody,

In the database there's a table with checked in and out events. I want to calculate a cumulative total hours per week.

Currently I have this formula to calculate, but that give the results in decimals:

sum (((check_out - CHECK_IN)*24*60*60)) over (partition by employee_nr, to_char( check_in,'YYYY-IW') order by check_in) as Total_Per_Week

This is the requested result (the last column is what it should be):

Employee NrCheck InCheck OutHours InNew Cum. Total
5911 01-04-2019 07:23:5401-04-2019 16:09:20+00 08:45:26.000000 8:45
5911 02-04-2019 06:35:1202-04-2019 15:53:26+00 09:18:14.00000018:03
5911 04-04-2019 07:28:0204-04-2019 15:49:40+00 08:21:38.00000026:24
5911 05-04-2019 06:08:2005-04-2019 16:05:10+00 09:56:50.00000036:20

So the cumulative total goes over 24 hours, which it extra difficult.

Any ideas to achieve this?

Thanks in advance.

Regards,

Geert Joosten.

This post has been answered by Frank Kulash on Aug 13 2019
Jump to Answer
Comments
Post Details
Added on Aug 13 2019
7 comments
399 views