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!

Subtract current value from previous row value

764958May 11 2010 — edited May 12 2010
Hi,

Can anybody help me in this.


Id Start Date End Date
-----------------------------------------------------------------------------------------
34 4/12/2010 8:02:33 AM 4/12/2010 8:02:08 AM
35 4/12/2010 8:06:14 AM 4/12/2010 8:05:45 AM
36 4/12/2010 8:09:19 AM 4/12/2010 8:08:49 AM
80 4/12/2010 8:11:36 AM 4/12/2010 8:11:11 AM
38 4/12/2010 8:14:11 AM 4/12/2010 8:13:44 AM
94 4/12/2010 8:14:33 AM 4/12/2010 8:14:01 AM

I need a query which can show time difference between end date of one row and start date of previous row

for example

Id Start Date End Date
--------------------------------------------------------------------------------------------------------------------------
34 4/12/2010 8:02:33 AM 4/12/2010 8:02:08 AM 0 (since there is no pre row)
35 4/12/2010 8:06:14 AM 4/12/2010 8:05:45 AM 3.45sec (end date - start date for id 34)
36 4/12/2010 8:09:19 AM 4/12/2010 8:08:49 AM
80 4/12/2010 8:11:36 AM 4/12/2010 8:11:11 AM
38 4/12/2010 8:14:11 AM 4/12/2010 8:13:44 AM
94 4/12/2010 8:14:33 AM 4/12/2010 8:14:01 AM


Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 9 2010
Added on May 11 2010
4 comments
3,065 views