select case when "Average fee" < 0.0001 then 'Less Than 0.0001 AVAX'
when "Average fee" between 0.0001 and 0.001 then 'Between 0.0001 and 0.001 AVAX'
when "Average fee" between 0.001 and 0.01 then 'Between 0.001 and 0.01 AVAX'
when "Average fee" between 0.01 and 0.1 then 'Between 0.01 and 0.1 AVAX'
when "Average fee" between 0.1 and 1 then 'Between 0.1 and 1 AVAX'
else 'More Than 1 AVAX' end as type,
count (DISTINCT origin_to_address) as "Number of dApps"
from (select origin_to_address,
avg(tx_fee) as "Average fee"
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)
group by 1
order by 2 desc