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!

Difference between two rows of a table.

TauceefMay 14 2013 — edited May 15 2013
Hi All,

I have a requirement where I need to calculate the difference of a column, but the values are in two rows.

Its exactly like this, I am having a table where in I have stored incidents with their status and their modified dates

example:
Incident_Id : Status : Modified_Date(in seconds from a specific date)
1 : 1 : 9080890
1 : 2 : 9080999
1 : 3 : 9081900
2 : 1 : 10000900
2 : 2 : 10001000
2 : 3 : 10002000

Now the requirement is I have to show the time spent by each incident in each status.

ie for status 1 I need the difference between modified date of status 2 and modified date of status 1 likewise

for status 2 need the difference between modified date of status 3 and modified date of status 2 and so on.

the actual result I need is like this

Incident_Id : Status : Timespent
1: 1: (modified_date(status2) - modified_date(status1))


Please help me to write the query for this.

Regards,
Tauceef
This post has been answered by 915396 on May 14 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2013
Added on May 14 2013
3 comments
1,834 views