select *
from (
select restype,reqtime,Flag-RN as Flag2,count(Flag-RN) over (partition by restype,(Flag-RN)) as Flag3
from (
select restype,reqtime,( trunc(sysdate,'DD')-trunc(reqtime,'DD') ) as Flag,
row_number() over (partition by restype order by reqtime) as RN
from (select distinct restype,reqtime from temp) t1
) t2
) t3
where Flag3>=7