CryptoGowdaNFT Holders
    Updated 2024-05-13
    with holder_counts as (
    SELECT
    nft_address,
    nft_to_address AS holder,
    COUNT(ez_nft_transfers_id) AS received_count
    FROM
    base.nft.ez_nft_transfers
    WHERE
    nft_address = lower('{{contract_addy}}')
    GROUP BY
    1,
    2
    ),
    sender_counts AS (
    SELECT
    nft_address,
    nft_from_address AS sender,
    COUNT(ez_nft_transfers_id) AS sent_count
    FROM
    base.nft.ez_nft_transfers
    WHERE
    nft_address = lower('{{contract_addy}}')
    GROUP BY
    1,
    2
    )

    SELECT
    hc.nft_address,
    hc.holder,
    hc.received_count - COALESCE(sc.sent_count, 0) AS current_amount_held
    FROM
    holder_counts hc
    LEFT JOIN sender_counts sc ON hc.holder = sc.sender
    WHERE
    hc.received_count - COALESCE(sc.sent_count, 0) > 0
    QueryRunArchived: QueryRun has been archived