Home » SQL & PL/SQL » SQL & PL/SQL » Time difference between two task (oracle 10g)
Time difference between two task [message #387714] Fri, 20 February 2009 06:32 Go to next message
ravi214u
Messages: 153
Registered: February 2008
Location: CANADA
Senior Member
Hi,

I have a table which will record the timing of particular task started and completed as shown below.
The task will update the status in same column with new entry.
So i observe that there is a lag in end of first process and start of second process in seconds.
I want to write a query which will capture this lag time. Can any body give some hint about this.



 TASK_ID  MIN(TIMESTAMP)              MAX(TIMESTAMP)	TIME_DIFFERENCE
Task1	2/19/2009 3:54:14 PM	2/19/2009 3:54:24 PM	0 HOURS 0 MINUTES 10 SECS 
Task2	2/19/2009 3:54:32 PM	2/19/2009 3:55:27 PM	0 HOURS 0 MINUTES 55 SECS 
Task3	2/19/2009 3:55:59 PM	2/19/2009 3:56:02 PM	0 HOURS 0 MINUTES 3 SECS 
Task4	2/19/2009 3:56:10 PM	2/19/2009 3:56:34 PM	0 HOURS 0 MINUTES 24 SECS 
Task5	2/19/2009 3:57:02 PM	2/19/2009 3:58:28 PM	0 HOURS 1 MINUTES 26 SECS 



thanks
Re: Time difference between two task [message #387717 is a reply to message #387714] Fri, 20 February 2009 06:33 Go to previous messageGo to next message
trivendra
Messages: 208
Registered: October 2007
Location: Noida, India
Senior Member
Look for LAG and LEAD functions.
Re: Time difference between two task [message #387718 is a reply to message #387714] Fri, 20 February 2009 06:39 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@ravi214u,

You can use LAG/LEAD Analytical Functions.
Some basic Examples have been given in this page.

Hope this helps.

Regards,
Jo
Re: Time difference between two task [message #387720 is a reply to message #387714] Fri, 20 February 2009 06:51 Go to previous message
Michel Cadot
Messages: 64132
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Always post a Test case: create table and insert statements along with the result you want with these data.

Regards
Michel
Previous Topic: Is there a more effective or better way to write this?
Next Topic: Materialize hint strange behavior (?) (merged 7)
Goto Forum:
  


Current Time: Thu Dec 08 00:25:24 CST 2016

Total time taken to generate the page: 0.05373 seconds