Query editor
WITH first_buyers AS (SELECTtrader_id AS wallet_address,MIN(block_time) AS first_buy_time,token_bought_amount AS first_buy_amount,token_sold_amount AS first_cost_amount,token_bought_symbol,token_sold_symbol,amount_usd AS first_buy_usdFROM dex_solana.tradesWHERE blockchain = 'solana'AND token_bought_mint_address = '{{token_address}}'AND token_bought_amount > 0GROUP BY trader_id, token_bought_amount, token_sold_amount, token_bought_symbol, token_sold_symbol, amount_usdORDER BY first_buy_time ASCLIMIT 100),-- All buys by these walletsall_buys AS (SELECTt.trader_id AS wallet_address,t.block_time,t.token_bought_amount,t.token_sold_amount,t.amount_usdFROM dex_solana.trades tJOIN first_buyers fb ON t.trader_id = fb.wallet_addressWHERE t.blockchain = 'solana'AND t.token_bought_mint_address = '3zJ7RxtzPahndBTEn5PGUyo9xBMv6MJP9J4TPqdFpump'),-- All sells by these walletsall_sells AS (SELECTt.trader_id AS wallet_address,t.block_time,t.token_sold_amount,t.token_bought_amount,t.amount_usdFROM dex_solana.trades tJOIN first_buyers fb ON t.trader_id = fb.wallet_addressWHERE t.blockchain = 'solana'AND t.token_sold_mint_address = '3zJ7RxtzPahndBTEn5PGUyo9xBMv6MJP9J4TPqdFpump'),-- Wallet activity summarywallet_summary AS (SELECTfb.wallet_address,fb.first_buy_time,fb.first_buy_amount,fb.first_cost_amount,fb.token_bought_symbol,fb.token_sold_symbol,fb.first_buy_usd,-- Total boughtCOALESCE(SUM(ab.token_bought_amount), fb.first_buy_amount) AS total_bought,COALESCE(SUM(ab.amount_usd), fb.first_buy_usd) AS total_bought_usd,