Se eu entendi corretamente, você pode fazer algo assim:
select count(*)
from (select listagg(flag) within group (order by dt) as flags
from temp
) x
where not regexp_like(flags, 'HH|EE|HS|SE');
Alternativamente, você pode usar
lag()
:select (case when count(*) = sum(case when flag2 not in ('HH', 'EE', 'HS', 'SE')
then 1 else 0
end) as return_value
from (select t.*,
(lag(flag) over (order by dt) || flag) as flag2
from temp
) t;