Spectertotal amount
    Updated 2024-10-16
    WITH ChainV AS (
    SELECT Date_trunc('day', block_timestamp) AS date, 'blast' AS chain,
    tx_hash, amount_usd
    FROM blast.core.ez_native_transfers
    WHERE from_address = '0x59b9ac688e39a14b938ac8c3269db66d8adb9af6'
    --and to_address != '0xd00c70f9b78c63a36519c488f862df95b7a73d90'

    UNION ALL

    SELECT Date_trunc('day', block_timestamp) AS date, 'bsc' AS chain,
    tx_hash, amount_usd
    FROM bsc.core.ez_native_transfers
    WHERE from_address = '0x7e2cf06f092c9f5cf5972ef021635b6c8e1c5bb2'
    --and to_address != '0xd00c70f9b78c63a36519c488f862df95b7a73d90'

    UNION ALL

    SELECT Date_trunc('day', block_timestamp) AS date, 'polygon' AS chain,
    tx_hash, amount_usd
    FROM polygon.core.ez_native_transfers
    WHERE from_address = '0x8ccd9c0a9c084412416a85fd748c7f1e9b86442d'
    --and to_address != '0xd00c70f9b78c63a36519c488f862df95b7a73d90'
    )

    SELECT COALESCE(chain, 'Total') AS chain, -- 'Total' row for the overall sum
    sum(amount_usd) AS total_amount
    FROM ChainV
    GROUP BY ROLLUP(chain); -- ROLLUP adds a grand total row
    ORDER BY total_amount desc

    QueryRunArchived: QueryRun has been archived