with users as (
select
from_address,
sum(from_amount_usd) volume
from thorchain.defi.fact_swaps
group by 1
),
all_users as (
select
from_address,
volume,
case when volume < 1000 then '<$1.000'
when volume between 1000 and 10000 then '$.1000 - $10.000'
when volume between 10000 and 100000 then '$10.000 - $100.000'
when volume between 100000 and 1000000 then '$100.000 - $1.000.000'
else '>$1.000.000'
end typeuser
from users
)
select
typeuser as "Trading Volume",
count(from_address) as "Users"
from all_users
group by 1
order by 1