Updated 2023-06-01
    -- forked from DDU6 @ https://flipsidecrypto.xyz/edit/queries/23bfaf86-a7a8-4738-8db6-d4bd73c5c85b

    with tb1 as(SELECT
    *
    from ethereum.core.dim_labels
    where label_type='cex'
    )


    select
    BLOCK_TIMESTAMP::date as day,
    case when day>='2023-05-24' then 'After upgrade' else 'Before upgrade' end as period,
    'Sent to CEXs' as paths,
    count(distinct tx_hash) as no_transfer,
    count(distinct FROM_ADDRESS) as no_sender,
    sum(AMOUNT) as total_volume,
    avg(AMOUNT) as avg_volume,
    sum(total_volume) over (order by day) as cum_volume
    from ethereum.core.ez_token_transfers
    where CONTRACT_ADDRESS='0x65ef703f5594d2573eb71aaf55bc0cb548492df4'
    and ORIGIN_TO_ADDRESS in (select ADDRESS from tb1)
    and ORIGIN_FROM_ADDRESS not in (select ADDRESS from tb1)
    and BLOCK_TIMESTAMP>='2023-05-01'
    group by 1,2
    union ALL
    select
    BLOCK_TIMESTAMP::date as day,
    case when day>='2023-05-24' then 'After upgrade' else 'Before upgrade' end as period,
    'Receive from CEXs' as paths,
    count(distinct tx_hash) as no_transfer,
    count(distinct TO_ADDRESS) as no_sender,
    sum(AMOUNT) as total_volume,
    avg(AMOUNT) as avg_volume,
    sum(total_volume) over (order by day) as cum_volume
    from ethereum.core.ez_token_transfers
    where CONTRACT_ADDRESS='0x65ef703f5594d2573eb71aaf55bc0cb548492df4'
    Run a query to Download Data