Ali3NDaily Net USDT Swaps Sell Buy Over Time
    Updated 2023-02-04
    with selltable as (
    select block_timestamp::Date as date,
    case when date = '2022-12-09' then 'Coinbase Advise to Switch USDT to USDC'
    when date in ('2022-12-12','2022-12-13') then 'Binance News'
    else 'Other Days' end as timespan,
    sum (amount_in)*-1 as Sell_Volume
    from ethereum.core.ez_dex_swaps
    where token_in in ('0xdac17f958d2ee523a2206206994597c13d831ec7')
    and block_Timestamp >= CURRENT_DATE - 14
    group by 1,2),

    buytable as (
    select block_timestamp::Date as date,
    case when date = '2022-12-09' then 'Coinbase Advise to Switch USDT to USDC'
    when date in ('2022-12-12','2022-12-13') then 'Binance News'
    else 'Other Days' end as timespan,
    sum (amount_in_usd) as Buy_Volume
    from ethereum.core.ez_dex_swaps
    where token_out in ('0xdac17f958d2ee523a2206206994597c13d831ec7')
    and block_Timestamp >= CURRENT_DATE - 14
    group by 1,2)

    select t1.date,
    t1.timespan,
    buy_volume,
    sell_volume,
    sum (Sell_Volume + buy_volume) as Net_Volume,
    sum (net_volume) over (order by t1.date) as cumulative_net_volume
    from selltable t1 join buytable t2 on t1.date = t2.DATE
    group by 1,2,3,4
    Run a query to Download Data