Query editor
WITH current_holders AS (SELECT DISTINCTtoken_balance_owner AS ownerFROM solana_utils.latest_balancesWHERE token_mint_address = '9cRCn9rGT8V2imeM2BaKs13yhMEais3ruM3rPvTGpump'AND token_balance > 0),buy_volume AS (SELECTtrader_id AS wallet,SUM(amount_usd) AS usd_spentFROM dex_solana.tradesWHERE token_bought_mint_address = '9cRCn9rGT8V2imeM2BaKs13yhMEais3ruM3rPvTGpump'AND amount_usd IS NOT NULLGROUP BY trader_id),holder_cost AS (SELECTh.owner,b.usd_spentFROM current_holders hJOIN buy_volume bON h.owner = b.wallet)SELECTCASEWHEN usd_spent <= 200 THEN '$1 - $200'WHEN usd_spent <= 2000 THEN '$201 - $2,000'ELSE '>$2,000'END AS holder_category,COUNT(*) AS holders,ROUND(SUM(usd_spent), 2) AS total_usd_spent,ROUND(AVG(usd_spent), 2) AS average_usd_spentFROM holder_costGROUP BY 1ORDER BYCASEWHEN holder_category = '$1 - $200' THEN 1WHEN holder_category = '$201 - $2,000' THEN 2ELSE 3END;