with maintable as (
select tx_sender,
count (distinct tx_id) as TX_Count,
sum (fee) as Total_Fee,
avg (fee) as Average_Fee,
median (fee) as Median_Fee,
min (fee) as Minimum_Fee,
max (fee) as Maximum_Fee
from terra.core.fact_transactions
where fee_denom = 'uluna'
group by 1)
select case when Total_Fee < 1 then 'Less Than 1 LUNA'
when Total_Fee >= 1 and Total_Fee < 10 then '1 - 10 LUNA'
when Total_Fee >= 10 and Total_Fee < 100 then '10 - 100 LUNA'
else 'More Than 100 LUNA' end as type,
count (distinct tx_sender) as Users_count
from maintable
group by 1
order by 2 desc