Query editor
WITH daily_trading AS (SELECTtrader_id,DATE_TRUNC('day', block_time) as trade_date,SUM(CASEWHEN token_bought_mint_address = '2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump' THEN token_bought_amountWHEN token_sold_mint_address = '2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump' THEN -token_sold_amountEND) as daily_balance,--calculating balance using each transactionSUM(amount_usd) as volume_usd--summing to find daily balance per day for a traderFROM dex_solana.tradesWHERE (token_bought_mint_address = '2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump'OR token_sold_mint_address = '2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump')AND block_time >= TIMESTAMP '2023-10-31'--beginning of PNUT meme coinAND block_time <= CURRENT_TIMESTAMPGROUP BY trader_id, DATE_TRUNC('day', block_time)),trader_metrics AS (SELECTtrader_id,SUM(daily_balance) as total_balance,SUM(volume_usd) as total_volume_usd,COUNT(DISTINCT trade_date) as trading_daysFROM daily_tradingGROUP BY trader_id)SELECTtrader_id as "Wallet Address",total_balance as "Current PNUT Balance",total_volume_usd as "Total Volume (USD)",trading_days as "Days Active"FROM trader_metricsWHERE total_balance > 0ORDER BY total_volume_usd DESC--largest traders will be on top with thisLIMIT 10--only getting the top 10