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
I don't think you need the partition by statement:
WITH CTE AS (
SELECT ROW_NUMBER() OVER (ORDER BY columnOfNumbers) as ROW,
columnOfNumbers
FROM tableName
)
SELECT a.columnOfNumbers, a.columnOfNumbers - b.columnOfNumbers
FROM CTE a LEFT JOIN
CTE b
ON a.ROW = b.ROW + 1;
If you do need it, you should put in a column name as opposed to a table name.