I have a table like this, I want to update the value of AttemptNumber column based on record with the value based on the previous record.
| txnId | UserId | Retry | AttemptNumber |
|---|---|---|---|
| 1 | 12 | False | 0 |
| 2 | 12 | True | 1 |
| 3 | 12 | True | 2 |
| 4 | 12 | False | 0 |
| 5 | 12 | True | 1 |
| 6 | 12 | True | 2 |
| 7 | 12 | False | 0 |
Whenever I encounter Retry value as 'False', then I want to keep the AttemptNumber as 0.
Whenever I encounter Retry value as 'True', then I want to increment the value in the AttemptNumber.
Currently I don't have the column AttemptNumber in the table, I will create the column and update the values based on the value present in 'Retry'.