Query editor
WITH tokens_with_both_projects AS (SELECTtoken_sold_mint_address AS token_mint_addressFROM dex_solana.tradesWHEREproject IN ('pumpdotfun', 'raydium') -- Focus on the 'pumpdotfun' project onlyAND block_time >= CURRENT_TIMESTAMP - INTERVAL '24' HOURAND token_sold_mint_address != 'So11111111111111111111111111111111111111112'GROUP BY token_sold_mint_addressHAVING COUNT(DISTINCT project) = 2 -- Ensure the token is involved in both projects),wallets_that_bought_tokens AS (SELECTtoken_bought_mint_address,trader_idFROM dex_solana.tradesWHEREtoken_bought_mint_address IN (SELECT token_mint_address FROM tokens_with_both_projects) -- Tokens bought from the list of Step 1AND project = 'pumpdotfun' -- Focus on the 'pumpdotfun' project onlyAND block_time >= CURRENT_TIMESTAMP - INTERVAL '24' HOUR),grouped_wallets AS (SELECTtoken_bought_mint_address,trader_idFROM wallets_that_bought_tokensGROUP BY token_bought_mint_address, trader_id),wallets_with_multiple_tokens AS (SELECTtrader_id,COUNT(DISTINCT token_bought_mint_address) AS token_count -- Count how many tokens each wallet boughtFROM grouped_walletsGROUP BY trader_idHAVING COUNT(DISTINCT token_bought_mint_address) > 1 -- Only keep wallets that bought more than one token)SELECTwmt.trader_id,wmt.token_count,gw.token_bought_mint_addressFROM wallets_with_multiple_tokens wmtJOIN grouped_wallets gw ON wmt.trader_id = gw.trader_idORDER BY wmt.token_count DESC, gw.token_bought_mint_address;