Query editor
-- Step 1: Calculate total GOAT tokens bought by each traderWITH goat_trades AS (SELECTtrader_id,SUM(token_bought_amount) AS total_goat_bought -- Total GOAT tokens bought per traderFROMdex_solana.tradesWHEREtoken_bought_symbol = 'GOAT' OR token_sold_symbol = 'GOAT' -- Filter for GOAT tradesGROUP BYtrader_id),-- Step 2: Calculate the total amount of GOAT tokens tradedtotal_goat_traded AS (SELECTSUM(total_goat_bought) AS total_goat -- Sum of all GOAT tokens boughtFROMgoat_trades),-- Step 3: Calculate the percentage share of each tradershareholders AS (SELECTgt.trader_id,gt.total_goat_bought / t.total_goat * 100 AS percentage_share -- Trader's share in percentageFROMgoat_trades gtCROSS JOINtotal_goat_traded t)-- Step 4: Get the top 10 traders by percentage shareSELECTtrader_id,percentage_shareFROMshareholdersORDER BYpercentage_share DESC -- Sort by highest percentage shareLIMIT 10 -- Limit to top 10 traders