Eman-RazTotal Stats
    Updated 2024-04-01
    with final_tab as (with tab1 as (select amount_in_usd, origin_from_address, tx_hash
    from avalanche.defi.ez_dex_swaps
    where block_timestamp::date>='{{Start_Date}}' and block_timestamp::date<='{{End_Date}}' and
    (platform='trader-joe-v1' or platform='trader-joe-v2')
    ),
    ----------------------------------------------------------------------------------------------
    tab2 as (select amount_in_usd, origin_from_address, tx_hash
    from arbitrum.defi.ez_dex_swaps
    where block_timestamp::date>='{{Start_Date}}' and block_timestamp::date<='{{End_Date}}' and
    (platform='trader-joe-v1' or platform='trader-joe-v2')
    ),
    ----------------------------------------------------------------------------------------------
    tab3 as (select amount_in_usd, origin_from_address, tx_hash
    from bsc.defi.ez_dex_swaps
    where block_timestamp::date>='{{Start_Date}}' and block_timestamp::date<='{{End_Date}}' and
    (platform='trader-joe-v1' or platform='trader-joe-v2')
    ),
    ----------------------------------------------------------------------------------------------
    tab4 as (select amount_in_usd, origin_from_address, tx_hash
    from ethereum.defi.ez_dex_swaps
    where block_timestamp::date>='{{Start_Date}}' and block_timestamp::date<='{{End_Date}}' and
    (platform='trader-joe-v1' or platform='trader-joe-v2')
    )
    ----------------------------------------------------------------------------------------------

    select * from tab1 union all
    select * from tab2 union all
    select * from tab3 union all
    select * from tab4)

    select sum(amount_in_usd) as "Total Swap Volume (USD)", max(amount_in_usd) as "Max swap volume", avg(amount_in_usd) as "Avg swap volume",
    median(amount_in_usd) as "Median swap volume", count(distinct origin_from_address) as "Total Trader Count", count(distinct tx_hash) as "Total Swap Count",
    sum(amount_in_usd)/count(distinct origin_from_address) as "Avg swap volume per trader",
    round(count(distinct tx_hash)/count(distinct origin_from_address)) as "Avg Swap Count per trader"
    from final_tab
    Auto-refreshes every 3 hours
    QueryRunArchived: QueryRun has been archived