Query editor
WITHbots AS (SELECT *FROM dune.dune.result_solana_dex_bot_detection),-- Step 1: Calculate the weekly volume for bots and humansweekly_volumes AS (SELECTdate_trunc('week', block_time) AS week,CASEWHEN bots.signer IS NOT NULL THEN 'bot'ELSE 'person'END AS trader_type,SUM(amount_usd) AS volume,COUNT(*) AS swaps,COUNT(DISTINCT trader_id) AS tradersFROMdex_solana.trades spLEFT JOINbots ON bots.signer = sp.trader_idWHERE(token_bought_mint_address = 'GYKmdfcUmZVrqfcH1g579BGjuzSRijj3LBuwv79rpump'OR token_sold_mint_address = 'GYKmdfcUmZVrqfcH1g579BGjuzSRijj3LBuwv79rpump')GROUP BYdate_trunc('week', block_time),CASEWHEN bots.signer IS NOT NULL THEN 'bot'ELSE 'person'END),-- Step 2: Calculate the total weekly volume for both bots and humanstotal_weekly_volumes AS (SELECTweek,SUM(volume) AS total_volumeFROMweekly_volumesGROUP BYweek)-- Step 3: Calculate the percentage of volume for bots and humansSELECTwv.week,wv.trader_type,wv.volume AS trader_type_volume,twv.total_volume,ROUND(wv.volume / twv.total_volume * 100, 2) AS volume_percentageFROMweekly_volumes wvJOINtotal_weekly_volumes twvONwv.week = twv.weekORDER BYwv.week,wv.trader_type DESC;