id, operation_id, type, date
select *
from events
where
date > current_timestamp - interval '1 hour'
and type in ('open', 'open_page_1')
and not exists (
select type from events e
where e.operation_id = events.operation_id
and type not in ('open', 'open_page_1')
)
;
select operation_id
from <table>
group by operation_id
having sum(case when type in ('open', 'open_page_1') then 1 else 3 end) = 2