select
distinct b.event_TYPE,
COUNT(case when a.tx_succeeded = 'false' then 'Fail' end) as failed_tx,
COUNT(case when a.tx_succeeded = 'true' then 'Succeeded' end) as success_tx,
success_tx/failed_tx as Rate
from flow.core.fact_transactions a
inner join flow.core.fact_events b
on a.BLOCK_TIMESTAMP :: date = b.BLOCK_TIMESTAMP :: date
where a.tx_succeeded is not null
group by 1
order by 4 desc