ArioTraderJoe - Distribution
    Updated 2023-10-11
    -- forked from Distribution @ https://flipsidecrypto.xyz/edit/queries/7d0fd19f-8afa-4296-a25c-f89f76592f7b

    with
    price_{{Blokchain}} as (
    select
    date_trunc({{Granularity}}, HOUR) as date,
    TOKEN_ADDRESS,
    avg(PRICE) as avg_Price
    from
    {{Blokchain}}.price.ez_hourly_token_prices
    where 1=1
    and TOKEN_ADDRESS is not NULL
    group by
    1,
    2
    )
    select
    date::date as date,
    case
    when Swap_Vol <= 100 then 'A: Less than $100'
    when Swap_Vol between 100 and 1000 then 'B: $100-1k'
    when Swap_Vol between 1000 and 10000 then 'C: $1k-10k'
    when Swap_Vol between 10000 and 50000 then 'D: $10k-50k'
    when Swap_Vol between 50000 and 100000 then 'E: $50k-100k'
    when Swap_Vol between 100000 and 1000000 then 'F: $100k-1m'
    else 'G: More than $1m'
    end as status,
    count(distinct tx_hash) as "# Swap",
    round(sum(Swap_Vol), 2) as "Swap Volume ($)"
    from
    (
    SELECT
    date_trunc({{Granularity}}, block_timestamp) as date,
    tx_hash,
    AMOUNT_IN * avg_Price as Swap_Vol
    from
    Run a query to Download Data