I want to create a conditional int field called Sequence for each group of IDs.
The value 1 is given to Sequence for the first occurrence of a condition, otherwise increment the last count by 1. There are finite list of values for the field condition as illustrated below.
For a new group of ID, Sequence should initialise and start counting from 1.
| ID | Date | Condition | Seq |
|---|---|---|---|
| 01 | 01Jun14 | AAAAAAAAA | 1 |
| 01 | 02Jun14 | AAAAAAAAA | 2 |
| 01 | 03Jun14 | BBBBBBBBB | 1 |
| 01 | 04Jun14 | BBBBBBBBB | 2 |
| 01 | 05Jun14 | AAAAAAAAA | 3 |
| 01 | 06Jun14 | BBBBBBBBB | 3 |
| 01 | 07Jun14 | EEEEEEEEE | 1 |
| 02 | 01Jun14 | AAAAAAAAA | 1 |
| 02 | 02Jun14 | CCCCCCCCC | 1 |
| 02 | 03Jun14 | CCCCCCCCC | 2 |
| 02 | 04Jun14 | BBBBBBBBB | 1 |
| 02 | 05Jun14 | AAAAAAAAA | 2 |
| 02 | 06Jun14 | BBBBBBBBB | 2 |
| 03 | 01Jun14 | FFFFFFFFF | 1 |
| 03 | 02Jun14 | AAAAAAAAA | 1 |
| 03 | 03Jun14 | AAAAAAAAA | 2 |
| 03 | 04Jun14 | CCCCCCCCC | 1 |