I have the following table:
ID Value
1 X
1 Y
1 X
1 X
1 X
1 Y
1 X
2 X
2 Y
2 X
2 Z
2 Y
2 X
I need to count the number of non-Consecutive times X appears per ID. So My output should be:
ID COUNT
1 3
2 3
Using Select Count(*), ID From my_table where value = 'X'
calculates every occurrence of the value and not Non-Consecutive values only.
How do I solve this?