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 |
crofsx
Starting Member
2 Posts |
Posted - 2012-06-20 : 09:17:38
|
Hello,I have a table which indicates status information about insurance jobs, fields are as follows...ID - Job_ID - Status - CreateTimeThe CreateTime is the DateTime stamp for the job entering a given status and also the DateTime stamp for the job exiting the previous status.What I need to get to is a table of the formJob_ID - Status - StatusStartTime - StatusEndTimeIs this possible in SQL Server 2005? If so, how do you do it?Thanks, |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-20 : 10:04:25
|
select *, StatusEndTime = (select min(t2.StatusStartTime) from tbl t2 where t1.Job_ID = t2.Job_ID and t2.StatusStartTime > t1.StatusStartTime)frrom tbl t1==========================================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. |
 |
|
crofsx
Starting Member
2 Posts |
Posted - 2012-06-21 : 03:31:30
|
Works perfectly, thanks. |
 |
|
|
|
|