theericstoneETH CEX Flows Trailing Week
    Updated 2021-10-09
    with inflows as (
    select
    --date_trunc('day',block_timestamp) as date,
    coalesce(to_label,'unlabeled') as exchange_name,
    sum(amount_usd) as deposits_usd
    from ethereum.udm_events
    where block_timestamp >= getdate() - interval '7 days'
    and to_label_type = 'cex'
    and (from_label_type <> 'cex' OR from_label_type IS NULL)
    and symbol = 'ETH'
    and contract_address IS NULL
    group by 1
    ),

    outflows as (
    select
    --date_trunc('day',block_timestamp) as date,
    coalesce(from_label,'unlabeled') as exchange_name,
    sum(amount_usd) as withdrawals_usd
    from ethereum.udm_events
    where block_timestamp >= getdate() - interval '7 days'
    and from_label_type = 'cex'
    and (to_label_type <> 'cex' OR to_label_type IS NULL)
    and symbol = 'ETH'
    and contract_address IS NULL
    group by 1
    )

    select
    --coalesce(inflows.date, outflows.date) as date,
    coalesce(inflows.exchange_name,outflows.exchange_name) as exchange_name,
    inflows.deposits_usd,
    outflows.withdrawals_usd
    from
    inflows FULL JOIN outflows
    on inflows.exchange_name = outflows.exchange_name
    Run a query to Download Data