select
project_name as "dApp",
count(Distinct contract_address) as "Number of contracts",
count (distinct x.tx_hash) as "Number of txns",
sum(tx_fee) as "Total fees",
avg(tx_fee) as "Average fee per txn"
from avalanche.core.fact_transactions x join avalanche.core.fact_event_logs y on x.tx_hash = y.tx_hash
join avalanche.core.dim_labels z on y.origin_to_address = z.address
where x.block_timestamp >= '{{From_Date}}'
and x.block_timestamp <= '{{To_Date}}'
and label_type ilike 'dapp'
GROUP BY 1
ORDER BY 5 DESC
LIMIT 10