Query editor
WITH transfers AS (SELECTevt_block_time,"from" AS from_address,"to" AS to_address,value / 1e18 AS amountFROM erc20_ethereum.evt_TransferWHERE contract_address = from_hex('4B266366dc8fF4c0007943a679CBa1fDB845f98D')),balances AS (SELECTto_address AS wallet,SUM(amount) AS receivedFROM transfersGROUP BY to_address),outflows AS (SELECTfrom_address AS wallet,SUM(amount) AS sentFROM transfersGROUP BY from_address),net_balances AS (SELECTCOALESCE(b.wallet, o.wallet) AS wallet,COALESCE(b.received, 0) - COALESCE(o.sent, 0) AS balanceFROM balances bFULL OUTER JOIN outflows o ON b.wallet = o.wallet),positive_balances AS (SELECTwallet,balanceFROM net_balancesWHERE balance > 0),summary AS (SELECTCOUNT(*) AS total_holders,SUM(balance) AS total_balanceFROM positive_balances)SELECTp.wallet,p.balance,s.total_holders,s.total_balanceFROM positive_balances pCROSS JOIN summary sORDER BY p.balance DESC;