I am trying to find the difference between the current row and the previous row. However, I am getting the following error message:
The multi-part id
If you in SQL Server 2012+ You can use LAG.
SELECT columnOfNumbers
,columnOfNumbers - LAG(columnOfNumbers, 1) OVER (ORDER BY columnOfNumbers)
FROM tableName
Note: The optional third parameter of LAG is:
default
The value to return when scalar_expression at offset is NULL. If a default value is not specified, NULL is returned. default can be a column, subquery, or other expression, but it cannot be an analytic function. default must be type-compatible with scalar_expression.