KARTOD$RUNE holders
    Updated 2022-06-26
    WITH amount_received AS (
    SELECT
    to_address,
    SUM(rune_amount) as amount_received
    FROM thorchain.transfers
    GROUP BY to_address
    ),

    amount_sent AS (
    SELECT
    from_address,
    SUM(rune_amount) as amount_sent
    FROM thorchain.transfers
    GROUP BY from_address
    ),

    address AS (
    SELECT
    to_address,
    amount_received - amount_sent as rune_balance
    FROM amount_received
    INNER JOIN amount_sent ON amount_received.to_address = amount_sent.from_address
    WHERE rune_balance > 0
    ),
    ALL_HOLD AS (
    SELECT
    COUNT(DISTINCT to_address) AS "$RUNE holders"
    FROM address
    ),

    data as (
    SELECT
    rune_balance AS balance
    FROM address
    WHERE rune_balance > 0
    Run a query to Download Data