sql server - SQL Find difference between previous and current row -
I am trying to find the difference between the current row and the previous row. However, I'm getting the following error message.
The multi-part identifier "TableName" can not be constrained
Not sure how to fix the error
Thanks
The output will look like the following:.!
columnOfNumbers difference 1 zero 2 1 3 1 10 7 to 12 2 ....
code:
Usage Database; CTE with more than ROW_NUMBER (selected columnOfNumbers by tableName command) columnName from TableName) CTE Select from a left a.columnOfNumbers include a.columnOfNumbers = b.columnOfNumbers = b.columnOfNumbers and a.ROW = b on CTE B ROW + 1
; As with tblDifference (select ROW_NUMBER) (select RAW_NUMBER) as RowNumber, select TableOfNumbers from TableName), cur.columnOfNumbers, cur.columnOfNumbers - tblDifference from previous.columnOfNumbers CUR Left External TblDifference .RowNumber = previous.RowNumber + 1
Comments
Post a Comment