binhachonDEX Popularity: Tinyman, Algofi, Pactfi - #2
    Updated 2022-05-19
    with swap_volume as (
    select
    swap_program,
    swap_from_amount as swap_amount
    from flipside_prod_db.algorand.swaps
    where swap_from_asset_id = 0
    and block_timestamp::date >= '2022-04-01'
    union all
    select
    swap_program,
    swap_to_amount
    from flipside_prod_db.algorand.swaps
    where swap_to_asset_id = 0
    and block_timestamp::date >= '2022-04-01'
    ),
    distribution as (
    select
    swap_program,
    case
    when swap_amount < 100 then '1. Less than 100'
    when swap_amount < 1000 then '2. 100 - 1000'
    when swap_amount < 10000 then '3. 1000 - 10000'
    when swap_amount < 100000 then '4. 10000 - 100000'
    else '5. >100000' end
    as category,
    sum(swap_amount) as volume,
    100 * ratio_to_report(volume) over (partition by swap_program) as perc
    from swap_volume
    group by 1, 2
    )
    select * from distribution
    Run a query to Download Data