This should do it
WITH CTE AS (
SELECT
rownum = ROW_NUMBER() OVER (ORDER BY Name, RowNo),
Salary, RowNo, Name
FROM myTable
)
SELECT
cur.RowNo, cur.Name, cur.Salary, ISNULL(prev.Salary,0)
FROM CTE cur
LEFT OUTER JOIN CTE prev on prev.rownum = cur.rownum - 1
You said there was no row number in your table but your data showed a RowNo... it doesn't really matter but you might want to change the
ORDER BY
clause. Edit - just re-read your question - apologies about my confusion on RowNo - ignore me :-)
This produces the following results:
ROWNO NAME SALARY COLUMN_3
1 Alan 20000 0
2 Alan 22000 20000
3 Alan 24000 22000