with add_col as (
select tx_hash
from flipside_prod_db.ethereum_core.fact_event_logs
where event_name = 'LogAddCollateral' and contract_address = '0x6eafe077df3ad19ade1ce1abdf8bdf2133704f89'
),
col as (
select from_address, sum(amount_usd) as amount
from flipside_prod_db.ethereum_core.ez_token_transfers
where tx_hash in (select tx_hash from add_col)
group by 1
)
select case
when amount = 0 then '0'
when amount > 0 and amount <= 10 then '0-10'
when amount > 10 and amount <= 100 then '10-100'
when amount > 100 and amount <= 1000 then '100-1000'
when amount > 1000 and amount <= 10000 then '1000-10000'
when amount > 10000 and amount <= 100000 then '10000-100000'
when amount > 100000 and amount <= 1000000 then '100000-1000000'
when amount > 1000000 and amount <= 10000000 then '1000000-10000000'
else 'more than 10000000' end as dis, count(*)
from col
group by 1