Tricky for me to define the problem, maybe you understand it through my dummy data.
I have this data:
PK, TaskPK
1, 1
2, 1
3, 2
4, 2
5, 5
6, 1
7, 1
8, 2
9, 2
10, 5
11, 5
Now I have to count TaskPK so, I make this query
Select PK, TaskPK, Count(*)
From tbl
Group by TaskPK
Iit brought this result
TaskPK, Count(*)
1, 4
2, 4
5, 3
But I want slight different result Like this
TaskPK, Count(*)
1, 2
2, 2
5, 1
1, 2
2, 2
5, 2
The above result based on consecutive data occurrence, as TaskPK start with 1 (it group together), then it change it 2 (it group together), then 5 (it group together) taskPK. But as TaskPK again shift to 1, then it should group seperatly not link with previous occurrence of 1, this task seperately count, is this possible?