By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
5 rows affected
| person | period | Cost_Center | seqnum | seqnum_2 | immediate_prev_cost_center | prev_cost_center |
|---|---|---|---|---|---|---|
| 123 | 2019003 | 1 | 1 | 1 | null | null |
| 123 | 2019004 | 1 | 2 | 2 | 1 | null |
| 123 | 2019005 | 2 | 3 | 1 | 1 | 1 |
| 123 | 2019006 | 2 | 4 | 2 | 2 | 1 |
| 123 | 2019007 | 3 | 5 | 1 | 2 | 2 |
Warning: Null value is eliminated by an aggregate or other SET operation.