with base as (select
proposer,
contract_name,
count(distinct(tx_id)) as count_tx
from flow.core.fact_transactions a
left join flow.core.dim_contract_labels b
on account_address = proposer
where block_timestamp >= '2022-05-09'
and tx_succeeded != 'TRUE'
group by 1,2
order by 3 desc
limit 10),
base2 as (select distinct(tx_id) as tx_ids
from flow.core.fact_transactions
where proposer in (select proposer from base))
select event_contract,
event_type,
tx_id -- count(distinct(tx_id)) as count_tx
from flow.core.fact_events
where tx_id in (select tx_ids from base2)
and tx_succeeded != 'TRUE'
--group by 1,2
order by 3 desc
limit 10