I tried something like this but it's not working the way I want.
declare @Temp1 table
(
RowID int,
Serial_Num varchar(3),
ReadingDate datetime,
M_Counter int,
Dyn_Counter int
)
insert into @Temp1
select ROW_NUMBER() over (order by Serial_Num, ReadingDate), *
from MyTable T
select...
After processing data I just found today that there are some cases when prior month's reading is not there!! In that case sql should go back previous month to get the reading and do calculation. I will put this in store procedure and Calculation needed for last 4 months only (CurrentMonth + 3...
I am using SQL server 2008 and I have following Table with millions of rows...Here are few sample records
Serial_Num ReadingDate M_Counter Dyn_Counter
XYZ 3/15/2014 100 190
XYZ 4/18/2014 140 240
XYZ 5/18/2014 200 380...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.