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 |
|
headstrong
Starting Member
3 Posts |
Posted - 2005-11-29 : 01:47:45
|
| I will try to explain this as best as I canLets say I have a querySELECT * FROM users WHERE pid=55and the result isbill 55 1/1/2005 1:25bob 55 1/1/2005 1:35ray 55 1/1/2005 1:38bert 55 1/1/2005 1:42I need to get the elapse time, (I guess using the datediff) using the first row and the next for comparing. so elapsetime would be 10 minutes for the first 2 rows and 5 minutes for the next 2 rows.not sure how to do this, can it be done in SQL or will I need to do some vbscript. any help?thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-29 : 02:03:18
|
| Select T1.col1,DateDiff(minute,T1.datecol,T2.datecol) from users T1 inner join users T2on T1.datecol<T2.datecolMadhivananFailing to plan is Planning to fail |
 |
|
|
JoshuaF
Starting Member
10 Posts |
Posted - 2005-11-29 : 05:29:02
|
| Try a collated subquery. They have their uses..Select U1.FirstName, U1.CreatorTimeStamp, DateDiff(minute, U1.CreatorTimeStamp, (select top 1 U2.CreatorTimeStamp from Users U2 where U2.UserID > U1.UserID))from Users U1 |
 |
|
|
|
|
|