Hi,
I have a query that I am having some trouble with.
..produces...Code:select jobid, lastruntime from jobs where jobid= 9740 order by lastruntime desc
What I need to do is create another column that utilizes the DATEDIFF function to find the time between lastruntime. I know I can use DATEDIFF, but the problem lies with the fact that this table (jobs) has no unique column.Code:jobid lastruntime 9740 2012-07-17 12:07:29.777 9740 2012-07-17 11:48:46.127 9740 2012-07-17 11:29:54.050 9740 2012-07-17 11:09:23.807 9740 2012-07-17 10:49:55.010
i can use the following query, but it requires me to manually enter in the start and end dates...
What I need is results like the following....Code:select datediff (minute, '2012-07-13 13:23:31.793', '2012-07-13 13:45:13.250') as 'time between lastruntime'
Can anyone help me implement this logically...?Code:userid logintime time between lastruntime 9740 2012-07-17 12:07:29.777 -19 9740 2012-07-17 11:48:46.127 -19 9740 2012-07-17 11:29:54.050 etc... 9740 2012-07-17 11:09:23.807 etc.. 9740 2012-07-17 10:49:55.010 etc..
Thanks!




Reply With Quote