talebimorteza_72the volume of Algorand that moved to cex
    Updated 2022-02-24
    with
    cex_address as (
    select distinct
    address,
    label,
    label_subtype,
    address_name
    from algorand.labels
    where label_type = 'cex'
    and label not like '%group%'
    ),
    cex_transfers as (
    select
    block_timestamp,
    tx_id,
    sender,
    receiver,
    amount,
    label as cex,
    case when p.receiver=c.address then 'to cex'
    else 'from cex' end as type
    from algorand.payment_transaction p join cex_address c on p.receiver=c.address
    where block_timestamp >= '2021-01-01'
    )

    select
    date(block_timestamp) as date,
    cex,
    --type,
    count(tx_id) as trans,
    sum(amount) as amts
    from cex_transfers
    where type = 'to cex'
    group by 1,2
    order by cex