Query editor
-- Calculate tokens received by each wallet for the specific contract addressWITH TokensReceived AS (SELECT"to" AS wallet,tokenIdFROMerc721_ethereum.evt_transferWHEREcontract_address = from_hex('0x9C8fF314C9Bc7F6e59A9d9225Fb22946427eDC03')),-- Calculate tokens sent by each wallet for the specific contract addressTokensSent AS (SELECT"from" AS wallet,tokenIdFROMerc721_ethereum.evt_transferWHEREcontract_address = from_hex('0x9C8fF314C9Bc7F6e59A9d9225Fb22946427eDC03')),-- Combine received and sent tokens to find current holdingsTokenMovements AS (SELECTCAST(wallet AS VARCHAR) AS wallet,tokenId,1 AS changeFROMTokensReceivedUNION ALLSELECTCAST(wallet AS VARCHAR) AS wallet,tokenId,-1 AS changeFROMTokensSent),-- Aggregate changes to get net balance for each wallet and tokenNetBalances AS (SELECTwallet,tokenId,SUM(change) AS net_balanceFROMTokenMovementsGROUP BYwallet,tokenId),-- Filter out tokens that have been completely transferred outCurrentHoldings AS (SELECTwallet,tokenIdFROMNetBalancesWHEREnet_balance > 0),-- Delegate changes and current delegates calculationDelegateChanges AS (