Query editor
WITH wallet_actions AS (SELECTtx_signer as wallet,COUNT(*) as action_countFROM jupiter_solana.aggregator_swapsWHERE block_time >= CURRENT_DATE - INTERVAL '30' DAYGROUP BY tx_signer),ranked_wallets AS (SELECTwallet,action_count,SUM(action_count) OVER () as total_actions,SUM(action_count) OVER (ORDER BY action_count DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as cumulative_actions,ROW_NUMBER() OVER (ORDER BY action_count DESC) as wallet_rankFROM wallet_actions),bottom_50_threshold AS (SELECTMAX(CASE WHEN cumulative_actions <= total_actions / 2 THEN wallet_rank ELSE 0 END) as top_50_cutoffFROM ranked_wallets),metrics AS (SELECTSUM(CASE WHEN rw.wallet_rank > b.top_50_cutoff THEN rw.action_count ELSE 0 END) as bottom_50_actions,SUM(rw.action_count) as total_actionsFROM ranked_wallets rwCROSS JOIN bottom_50_threshold b)SELECTbottom_50_actions,total_actions,ROUND(100.0 * bottom_50_actions / NULLIF(total_actions, 0), 2) as bottom_50_percentageFROM metrics