with base as (
select borrower_address,
sum(borrowed_usd) as volume
from ethereum.aave.ez_borrows
where symbol in ('MKR','SNX','UNI')
and aave_version = 'Aave V2'
group by 1
)
select case when volume <1000 then 'Less Than 1,000M USD Volume'
when volume >= 1000 and volume < 5000 then '1,000M - 5,000M USD Volume'
when volume >= 5000 and volume < 10000 then '5,000M - 10,000M USD Volume'
when volume >= 10000 and volume < 50000 then '10,000M - 50,000M USD Volume'
when volume >= 50000 and volume < 100000 then '50,000M - 100,000M USD Volume'
when volume >=100000 then 'More Than 100,000M USD Volume'
end as type,
count(DISTINCT borrower_address) as users
from base
group by 1