sql server - How to Get current column value, Previous Column Value -


How to get the previous column value?

  IIf id1 = id2 then show previous column id1 value id1 id2 1001 1001 1002 1002 1003 1003  

so on ...

  ID1, id2, iff id2 = id 1, then erase the previous id value 1 Idadjusted  

output

  Id1 id2 id3 (expected) 1001 1001 ** 1000 ** 1002 1002 ** 1001 ** 1003 1003 ** 1002 **  

So on ...

I want to sell the last column value id1

My query