Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | rickniStarting Member
 
 
                                        1 Post | 
                                            
                                            |  Posted - 2012-12-18 : 19:08:08 
 |  
                                            | I need to write a query calculating time between this row's task and next row's task.datetime               task     description    timespent1/1/2012 00:50:12.5    Status    Work11/1/2012 00:54:13.4    Status    Break31/1/2012 01:07:29.5    Status    Work2 |  |  
                                    | nigelrivettMaster Smack Fu Yak Hacker
 
 
                                    3385 Posts | 
                                        
                                          |  Posted - 2012-12-19 : 03:53:59 
 |  
                                          | select *, datetime - (select min(datetime) from tbl t2 where t2.datetime > t.datetime)from tbl torder by datetime==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |  
                                          |  |  |  
                                |  |  |  |