>I don't understand your question. BTW, the query should be
>
>select * from cteRanges where Grp = 0 and RowNumber >=2 and Status = 7
>
>The idea is to mark consecutive ranges of the particular status.
Yes, I did added the Status=7. But, that would not work.
The sequence could be as follow:
Created
Uploaded
Completed
Assigned
Completed
Completed
So, basically, in that case, only the last one should be removed as the first Completed is followed by a different status. The duplicates are only for those Completed, at the end.