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 KadiyalaPosted Mar 12, 2009, 10:47 AM
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
SUDHANAS reddyPosted Mar 12, 2009, 1:05 AM
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
Mahesh ChandPosted Mar 10, 2009, 10:26 AM
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.
Vijaya KadiyalaPosted Mar 10, 2009, 9:41 AM
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