hessUsers Breakdown Based on Borrowed Volume in USD
    Updated 2023-03-09
    with final as ( select BORROWER_ADDRESS, symbol, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(BORROWER_ADDRESS)) as total_user,
    sum(BORROWED_USD) as total_volume, avg(BORROWED_USD) as avg_volume,
    median(BORROWED_USD) as median_volume, max(BORROWED_USD) as max_volume, min(BORROWED_USD) as min_volume
    from ethereum.aave.ez_borrows
    where symbol in ('SNX','UNI','MKR')
    and AAVE_VERSION = 'Aave V2'
    group by 1,2)

    select count(DISTINCT(BORROWER_ADDRESS)) as total_user,symbol,
    case when total_volume <= 5 then 'Below 5$'
    when total_volume <= 10 then '5-10$'
    when total_volume <= 25 then '10-25$'
    when total_volume <= 50 then '25-50$'
    when total_volume <= 100 then '50-100$'
    when total_volume <= 1000 then '100-1K$'
    when total_volume <= 10000 then '1K-10K$'
    when total_volume <= 100000 then '10K-100K$'
    when total_volume <= 1000000 then'100K-1M$'
    when total_volume > 1000000 then '+1M$' end as category
    from final
    group by 2,3
    HAVING category is not null
    Run a query to Download Data