SQLTeam.com | Weblogs | Forums

How to subtract row 1 from row 2 and insert the result in row c3?

tsql
sql2012

#1

I am looking for a code that can subtract the returns of RANK_1 from RANK_5 and consequently insert the results in the row RANK_5M1.. (there are 121 columns)

I just need the code for the first column (2006-12-30), since I already have a code to loop through all the columns.

Thanks for the help!


#2

Look at the LEAD and LAG windowing functions. They can help you do that kind of thing