superflyTerra Richlist
    Updated 2022-12-26
    with
    received as (
    SELECT
    receiver,
    sum(cast(amount as int)) as total_received
    FROM
    terra.core.ez_transfers
    WHERE tx_succeeded = TRUE AND currency = 'uluna'
    GROUP BY 1
    ),
    sent as (
    SELECT
    sender,
    sum(cast(amount as int)) total_sent
    FROM
    terra.core.ez_transfers
    WHERE tx_succeeded = TRUE AND currency = 'uluna'
    GROUP BY 1
    )

    SELECT
    address,
    (total_received - total_sent) as balance
    FROM
    (SELECT
    receiver as address,
    total_received,
    total_sent
    FROM
    received a
    LEFT JOIN sent b ON a.receiver = b.sender)

    LIMIT 100
    Run a query to Download Data