I have a table with every operations that appends before an event group by another value.
There is only 3 operations: R, E, P
+ ----------+----------+--------
If I followed you correctly, you can filter on records where order
is greater or equal than blocking
, and then do conditional aggregation:
select
rollcycle,
blocking,
max(iif(operation = 'R', 1, 0)) R,
max(iif(operation = 'E', 1, 0)) E,
max(iif(operation = 'P', 1, 0)) P
from mytable
where order >= blocking
group by rollcycle, blocking