select event_type,
count (case when tx_succeeded != 'TRUE' then 1 end) as Failed_TX,
count (case when tx_succeeded = 'TRUE' then 1 end) as Success_TX,
(Failed_TX / (Success_TX + Failed_TX)) * 100 as Failure_Rate
from flow.core.fact_events
where block_timestamp >= '2022-01-01'
and block_timestamp::date != CURRENT_DATE
group by 1 having Failure_Rate > 0
order by Failure_Rate