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!

Calculating time differences between multiple rows

936796May 11 2012 — edited May 15 2012
Hi,

I have a table as below:

ID EVENT DATE
1 Start 03/05/2012 13:00:00
1 Stop 04/05/2012 15:00:00
1 Start 07/05/2012 09:00:00
1 Stop 09/05/2012 10:00:00
2 Start 06/08/2012 08:00:00
2 Stop 07/08/2012 10:00:00

I would like to calculate the total time span (in hours ideally) between 'Start' and 'Stop' for each ID, so have a rowset:

ID TimeSpan
---------------------
1 75
2 26

I would be grateful for any ideas how to solve this, ideally as a SQL solution or perhaps a function.

Many thanks!
Tom
This post has been answered by Stew Ashton on May 11 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2012
Added on May 11 2012
11 comments
6,777 views