sql server - SQL Select statements that returns differences in minutes from next date-time from the same table -


i have user activity table. want see difference between each process in minutes. more specific here partial data table.

date                |trantype|   prod          |    loc ----------------------------------------------------------- 02/27/12 3:17:21 pm | pick   | lirishgreenxl   |     e01c015 02/27/12 3:18:18 pm | pick   | lantheliconias  |     e01a126 02/27/12 3:19:00 pm | pick   | lantheliconial  |     e01a128 02/27/12 3:19:07 pm | pick   | lantheliconiaxl |     e01a129  

i want retrieve time difference in minutes, between first , second process, second , third , .... thank you

something work in ms sql, change field names match yours:

select a.actiondate, datediff(minute,a.actiondate,b.actiondate) diffmin    (select row_number() over(order actiondate) row, actiondate  [dbo].[attendance])    inner join     (select row_number() over(order actiondate) row, actiondate  [dbo].[attendance]) b    on a.row +1  = b.row 


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -