denze-e7j2NUHolders by {{nft_contract_address}}
    Updated 2023-03-31
    -- fees paid by holders
    -- holding time
    -- # held

    WITH

    input_contracts AS (
    SELECT
    *
    FROM VALUES
    (lower('{{nft_contract_address}}'))
    AS data(nft_contract_address)
    WHERE data.nft_contract_address regexp '^0x[0-9a-fA-F]{40}$' -- check address is a valid format, i.e. starts with 0x and has 42 characters total
    )

    , input_time AS (
    SELECT
    CASE
    WHEN to_timestamp_ntz(data.snapshot_time) > date_trunc('minute', current_timestamp) THEN date_trunc('minute', current_timestamp)
    ELSE date_trunc('minute', to_timestamp_ntz(data.snapshot_time))
    END AS snapshot_time
    FROM VALUES
    ('{{snapshot_time}}')
    AS data(snapshot_time)
    )

    , input_creator_fee_perc AS (
    SELECT
    *
    FROM VALUES
    ({{creator_fee_perc}})
    AS data(creator_fee_perc)
    )

    -- get all nft transfers
    , nft_transfers AS (
    Run a query to Download Data