I have a table include "ID" and "Values", and wanted to know how many times does value "A" jumped into another values like below
| ID | Values |
|---|---|
| 1 | A |
| 1 | A |
| 1 | A |
| 1 | B |
| 1 | A |
| 1 | B |
| 1 | B |
| 1 | C |
| 1 | C |
| 1 | C |
| 1 | A |
| 2 | A |
| 2 | A |
| 2 | B |
| 2 | A |
| 2 | B |
| 2 | C |
| 2 | B |
Expected Result:
| ID | Values | Desired Output |
|---|---|---|
| 1 | A | 0 |
| 1 | A | 0 |
| 1 | A | 1 |
| 1 | B | 0 |
| 1 | A | 1 |
| 1 | B | 0 |
| 1 | B | 0 |
| 1 | C | 0 |
| 1 | C | 0 |
| 1 | C | 0 |
| 1 | A | 0 |
| 2 | A | 0 |
| 2 | A | 1 |
| 2 | B | 0 |
| 2 | A | 1 |
| 2 | B | 0 |
| 2 | C | 0 |
| 2 | B | 0 |
The final table should be like this:
| ID | Number of Transitions |
|---|---|
| 1 | 2 |
| 2 | 2 |