hessTop Swapped Tokens ( To ) Based on Volume
    Updated 2023-01-13
    with new as ( select min(block_timestamp::date) as date, from_address
    from ethereum.core.fact_transactions
    group by 2)
    ,
    new_user as ( select DISTINCT from_address
    from new
    where date >= CURRENT_DATE - 30)

    select case when block_timestamp < '2023-01-01' then '2022' else 'New Year' end as types, symbol_out, count(DISTINCT(tx_hash)) as total_tx,
    sum(amount_out_usd) as volume, rank() over (partition by types order by volume desc ) as rank
    from ethereum.core.ez_dex_swaps
    where block_timestamp >= CURRENT_DATE - 30
    and symbol_out is not null
    and amount_out_usd is not null
    and origin_from_address in (select from_address from new_user )
    group by 1,2
    qualify rank <= 5
    Run a query to Download Data