One of the tables has a date column in the sql server database. I need to calculate the time difference between all the consecutive rows i.e., difference between row1 and row2,differance between row2 and row3 and so on... I do know that this can be possible using cursors... Please help me in how to do so... My table structure is as follows
eventtime datetime
simid varchar(4)
finally i will calculate the minimun and maximun from that row datedifference values....
please help me
thanks in advance

Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Mar 10, 2009, 5:41 AM EDT
Hi,
This is not possible with simple SQL, you need to use T-SQL with the help cursors. btw what is the volume of the data??
Thanks -- Vijaya Kadiyala
Mahesh ChandRank #1 · 393.4K reputationPosted Mar 10, 2009, 6:26 AM EDT
You can create a View on your database and in View you can create new columns say Diff1, Diff2, Diff3 and so on. When you create your View, in SQL, you use Diff of Col1 and Col2 to fill Diff1. You need to look at SQL syntaxes how to create a View and how to get diff between two date columns.
Now you will use this View to get data in your application.
SUDHANAS reddy7 reputationPosted Mar 11, 2009, 9:05 PM EDT
iam new for this application ,please help me for a code
one day eventtime contains 30,000 eventtimes thats so its very large no.of data rows
thanks in advance
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Mar 12, 2009, 6:47 AM EDT
Hi,
Check out the below link, which will give you idea on how to write using Cursors.
http://www.jackdonnell.com/articles/SQL_CURSOR.htm
Thanks -- Vijaya Kadiyala
http://dotnetvj.blogspot.com