How to get value from previous line of SELECT statement result
If we have a table called cardevent and has the rows [ID (int), Value (Money)], and we have several rows, for example
ID
1
1
2
2
2
3
3
3
3
etc...
How to make one request that receives each row identifier, the value and the previous value of the row in which the data is displayed, as follows
ID --- Value ---Prev_Value
1 ----- 70 ---------- 0
1 ----- 90 ---------- 70
2 ----- 100 -------- 90
2 ------150 -------- 100
2 ------300 -------- 150
3 ----- 150 -------- 300
3 ----- 200 -------- 150
3 ---- 250 -------- 200
3 ---- 280 -------- 250
etc.
So can anyone help me get a better solution for such a problem?
Query Request Help
source
share