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 |
|
derach2000
Starting Member
37 Posts |
Posted - 2009-12-16 : 05:38:15
|
| Hi,I have a table in which there are sequnces of the same data sorted by time. Something like thisdatetime1 value1datetime2 value1datetime3 value2datetime4 value2datetime5 value1and so on.I need to get the duration of those sequnces with value2.Is this possible witout sequential processing like cursors, or loops?Regards |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-12-16 : 05:41:13
|
| hiDid you mean DATEDIFF function.-------------------------R... |
 |
|
|
derach2000
Starting Member
37 Posts |
Posted - 2009-12-16 : 05:56:47
|
| yes datediff function would be used eventualybut the problem is how to get the rigth rows to perform datediff... |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-16 : 05:58:41
|
| I think it can achieved only by sequential processing!!Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-16 : 06:11:10
|
| Try like this but i'm not sure about your Sequenceselect aa.index_i,aa.s_no, datediff(mi,aa.login,bb.login) diff_in_minfrom (select row_number() over(order by s_no) as index_i,* from(select row_number() over(order by login) as s_no,login from con_tbl_user_log ) a where s_no%2!=0 ) aainner join (select row_number() over(order by s_no) as index_i,* from(select row_number() over(order by login) as s_no,login from con_tbl_user_log ) a where s_no%2=0) bb on aa.index_i=bb.index_iSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
|
|
|