I have data like,
| index | flag |
|---|---|
| 0 | F |
| 1 | T |
| 2 | T |
| 3 | T |
| 4 | F |
| 5 | F |
| 6 | T |
And I want to write a Postgres query to convert this to,
| index | flag | group |
|---|---|---|
| 0 | F | 0 |
| 1 | T | 1 |
| 2 | T | 1 |
| 3 | T | 1 |
| 4 | F | 2 |
| 5 | F | 2 |
| 6 | T | 3 |
Where the group increments every time the flag changed between true and false.
How can I do this?