Query editor
withape_purchased_event_logs as (SELECTblock_hash,bytearray_ltrim (topic1) as playerAddress,bytearray_to_uint256 (topic2) as amountApePurchased,tx_hash as evt_tx_hash,block_time as evt_block_timeFROMethereum.logsWHEREtopic0 = 0x854b9652b54e460736e98c16b01accf780b6473ab6c733952caa8971a583f6faAND contract_address = 0x4e8ca5cb9FCA486d09EE7C8dBbFe99AC96Ec1982AND block_time >= TIMESTAMP '2023-06-22 00:00:00'),wallet_ape_used_details as (SELECTplayerAddress,concat('<a href=https://etherscan.com/address/',cast(playerAddress as VARCHAR),' target=_blank>EtherScan</a>') as link,SUM(amountApePurchased) as purchasedfromape_purchased_event_logs t1GROUP BY1)SELECTt1.playerAddress, t1.link, t1.purchased as amountApePurchased, t2.total_amount, t2.total_address_count, t2.total_amount / t2.total_address_count as avg_amount_per_addressfromwallet_ape_used_details t1JOIN (SELECTSUM(amountApePurchased) AS total_amount,COUNT(DISTINCT playerAddress) AS total_address_countFROM ape_purchased_event_logs) t2ON 1=1ORDER BYamountApePurchased DESCLIMIT{{top}}