Query editor
WITH insider_wallets AS (SELECT DISTINCT "to" AS walletFROM tokens_ethereum.transfersWHERE contract_address = from_hex(replace('{{token_address}}', '0x', ''))AND ("from" = 0x0000000000000000000000000000000000000000OR "from" = from_hex(replace('{{deployer_address}}', '0x', '')))AND "to" != 0x0000000000000000000000000000000000000000),allocations AS (SELECTiw.wallet,SUM(t.amount) AS initial_allocationFROM insider_wallets iwJOIN tokens_ethereum.transfers tON t."to" = iw.walletAND t.contract_address = from_hex(replace('{{token_address}}', '0x', ''))AND (t."from" = 0x0000000000000000000000000000000000000000OR t."from" = from_hex(replace('{{deployer_address}}', '0x', '')))GROUP BY iw.walletHAVING SUM(t.amount) > 0),recent_sells AS (SELECT"from" AS wallet,SUM(amount) AS sold_30d,MIN(block_time) AS first_sale_timeFROM tokens_ethereum.transfersWHERE contract_address = from_hex(replace('{{token_address}}', '0x', ''))AND block_time >= NOW() - INTERVAL '30' dayAND "from" IN (SELECT wallet FROM insider_wallets)AND "to" != 0x0000000000000000000000000000000000000000GROUP BY "from")SELECTa.wallet,a.initial_allocation,COALESCE(s.sold_30d, 0) AS sold_30d,CASEWHEN a.initial_allocation > 0THEN COALESCE(s.sold_30d, 0) / a.initial_allocation * 100ELSE 0END AS sold_pct_of_allocation,CASEWHEN s.first_sale_time IS NOT NULLTHEN DATE_DIFF('day', s.first_sale_time, NOW())ELSE NULLEND AS days_since_first_saleFROM allocations aLEFT JOIN recent_sells s ON s.wallet = a.walletORDER BY a.initial_allocation DESCLIMIT 20