Kaskoazul10 Popular CEX Sent to WEEKLY
    Updated 2022-02-22
    WITH CEX_ADDRESS AS (
    SELECT
    address,
    label
    FROM
    algorand.labels
    WHERE
    label_type = 'cex'
    ),

    SENT_TO_CEX AS (
    SELECT
    p.block_timestamp::date as fecha,
    p.receiver as Cex_address,
    c.label as Cex_label,
    p.amount as Sent_amount
    FROM
    algorand.payment_transaction p
    INNER JOIN CEX_ADDRESS c
    ON p.receiver = c.address
    WHERE
    p.block_timestamp >= '2021-01-01'
    )

    SELECT
    date_trunc('WEEK', fecha),
    Cex_label,
    sum(Sent_amount)
    FROM
    SENT_TO_CEX
    WHERE
    Cex_label in ('binance', 'kraken', 'coinbase', 'okex', 'group1', 'huobi', 'group25', 'algorand exchange 5', 'group6', 'group27')
    GROUP BY 1,2
    ORDER BY 3 DESC

    Run a query to Download Data