niloUntitled Query
    Updated 2022-11-18
    with base1 as (
    select swapper,
    swap_program
    from algorand.defi.fact_swap
    where swap_program = ('{{exchange}}')
    and (swap_from_amount >0
    or swap_to_amount >0)),
    base2 as (select address,
    sum (balance) as balance1
    from algorand.core.fact_account_current_balance
    where address in (select swapper from base1)
    group by 1
    order by 2 DESC)
    select case
    when balance1 <1 then 'Less than 1 ALGO'
    when balance1 >=1 and balance1 <=10 then 'Between 1 and 10 ALGO'
    when balance1 >10 and balance1 <=100 then 'Between 10 and 100 ALGO'
    when balance1 >100 and balance1 <=1000 then 'Between 100 and 1K ALGO'
    when balance1 >1000 and balance1 <=5000 then 'Between 1K and 5K ALGO'
    when balance1 >5000 and balance1 <=10000 then 'Between 5K and 10K ALGO'
    when balance1 >10000 and balance1 <=50000 then 'Between 10K and 50K ALGO'
    when balance1 >50000 and balance1 <=100000 then 'Between 50K and 100K ALGO'
    when balance1 >100000 then 'More than 100K ALGO' end as type,
    count (distinct address) as swappers
    from base2
    where balance1 is not null
    group by 1
    order by 2 DESC
    limit 20
    Run a query to Download Data