I apologies if I wasn't much clear on my ask or description. Also, Category is not much important to be called as C1,C2.... It can be 1,2,3,4,5,6.7,8 Note: 1)Stage for a id will start with either 1 or 2. 2)If stage starts with 1 then it can be either 1/2 for next YearMonth. Once Stage becomes 2 (which is possible only when stage-1 already exists or stage for an id start with 2 -It also means that If for any id, stage=2 then it won't be stage=1 again. 3)Once stage changes from 2 to 3, it wont be stage 1/2 again and it will only be 4 4) Once stage changes from 3 to 4, it wont be stage 1/2 again and it will only be 4 5) After 2), 3) and 4) will only occur e.g. id YearMonth Stage 1 200002 1 1 200003 2 1 200004 3 1 200005 3 1 200006 4 1 200007 3 1 200008 4 2 200001 2 2 200002 2 2 200003 3 2 200004 3 2 200005 4 2 200006 4 2 200007 3 2 200008 4 So for id=1, it starts with 1 and move forward. Once it reaches 4 it can be 3 and similarly once it reaches 3 it can only be 4 for id=2, it starts with 2 and then move forward. Again, once it reaches 4 it can be 3 and similarly once it reaches 3 it can only be 4. This will make rule-1 not valid.
... View more