How to get previous row data in sql server

后端 未结 4 1111
青春惊慌失措
青春惊慌失措 2021-01-20 23:53

I would like to get the data from previous row. I have used LAG function but did not get the expected result.

Table:-

col1  col2  col3
ABCD    1   Y
ABCD         


        
4条回答
  •  旧巷少年郎
    2021-01-21 00:40

    Thank you all for the replies. By using the lag function with partition I got the expected result. I missed to used partition previously and due to that I was getting wrong results.

提交回复
热议问题