By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
8 rows affected
| personId | eventName | dateid | dayssincecurrentevent | dayssinceinitialevent |
|---|---|---|---|---|
| 1 | InitialEvent | 2021-05-01 | 0 | 0 |
| 1 | InitialEvent | 2021-05-02 | 1 | 1 |
| 1 | InitialEvent | 2021-05-03 | 2 | 2 |
| 1 | InitialEvent | 2021-05-04 | 3 | 3 |
| 1 | AnEvent1 | 2021-05-05 | 0 | 4 |
| 1 | AnEvent1 | 2021-05-06 | 1 | 5 |
| 1 | AnEvent1 | 2021-05-07 | 2 | 6 |
| 1 | AnEvent4 | 2021-05-08 | 0 | 7 |
| 1 | AnEvent4 | 2021-05-09 | 1 | 8 |
| 1 | AnEvent4 | 2021-05-10 | 2 | 9 |
| 1 | AnEvent2 | 2021-05-11 | 0 | 10 |
| 1 | AnEvent2 | 2021-05-12 | 1 | 11 |
| 1 | ClosingEvent | 2021-05-13 | 0 | 12 |
| 2 | InitialEvent | 2021-05-10 | 0 | 0 |
| 2 | ClosingEvent | 2021-05-10 | 0 | 0 |
| 2 | ClosingEvent | 2021-05-11 | 1 | 1 |
| 2 | ClosingEvent | 2021-05-12 | 2 | 2 |
| 2 | AnEvent1 | 2021-05-13 | 0 | 3 |