with top10 as (
select
EVENT_CONTRACT,
CONTRACT_NAME,
-- EVENT_TYPE,
count (tx_id) as num_transactions
from flow.core.fact_events join flow.core.dim_contract_labels using (EVENT_CONTRACT)
where block_timestamp >= '2021-05-09'
and TX_SUCCEEDED = true
group by 1,2 order by num_transactions desc limit 10
)
select
BLOCK_TIMESTAMP::date as date ,
EVENT_CONTRACT,
CONTRACT_NAME,
-- EVENT_TYPE,
count (tx_id) as num_transactions,
sum (num_transactions) over (partition by EVENT_CONTRACT,CONTRACT_NAME order by date ) as growth
from flow.core.fact_events join flow.core.dim_contract_labels using (EVENT_CONTRACT)
where block_timestamp >= '2021-05-09'
and TX_SUCCEEDED = true
and EVENT_CONTRACT in (select EVENT_CONTRACT from top10 )
group by 1,2,3
-- order by num_transactions desc limit 10