I have data as below. I would like to add a new column that counts whenever column code changes and when ID changes it resets and counter to 1 and start counting.
ID code
1 10
1 10
1 11
1 11
1 21
1 21
2 10
2 10
2 11
2 11
2 11
2 14
2 15
result:
ID code counter
1 10 1
1 10 1
1 11 2
1 11 2
1 21 3
1 21 3
2 10 1
2 10 1
2 11 2
2 11 2
2 11 2
2 14 3
2 15 4