Updated 2023-05-10
    with
    prices as (SELECT TIMESTAMP::date as time,t1. SYMBOL,DECIMALS,t1.TOKEN_CONTRACT,avg (PRICE_USD) as USD

    from near.core.dim_token_labels t1
    left JOIN near.core.fact_prices t2 using (TOKEN_CONTRACT)

    WHERE SYMBOL like '%NEAR%' GROUP BY 1,2,3,4),

    jambo as (
    select
    date_trunc('Week', block_timestamp) as date,
    sum(AMOUNT_IN * USD) as Jumbo_Swap_Amount,
    count(distinct tx_hash) as Jumbo_Swap_Count
    from near.core.ez_dex_swaps
    left JOIN prices on TOKEN_IN_CONTRACT = TOKEN_CONTRACT AND time::date = BLOCK_TIMESTAMP::date
    where platform = 'v1.jumbo_exchange.near'
    group by 1 ),

    total as (select
    date_trunc('Week', block_timestamp) as date,
    sum(AMOUNT_IN * USD) as Total_Swap_Amount,
    count(distinct tx_hash) as Total_Swap_Count
    from near.core.ez_dex_swaps
    left JOIN prices on TOKEN_IN_CONTRACT = TOKEN_CONTRACT
    AND time::date = BLOCK_TIMESTAMP::date
    group by 1
    )
    select t1.date,Jumbo_Swap_Amount,Jumbo_Swap_Count,Total_Swap_Amount,Total_Swap_Count
    from total t1 join jambo using (date)


    Run a query to Download Data