Query editor
with bucketed_data as (selectcasewhen trade_usd < 100 then '1. <$100'when trade_usd < 1000 then '2. 100-1k'when trade_usd < 10000 then '3. 1k-10k'when trade_usd < 100000 then '4. 10k-100k'when trade_usd < 1000000 then '5. 100k-1m'else '6. >$1m'end as trade_size,frontend,count(distinct hash) as tx_count,sum(trade_usd) as volume,count(distinct user) as user_countfrom dune.flashbots.result_overall_ofwhere trade_usd is not nulland trade_pair = 'IDLE-WETH' or trade_pair = 'IDLE-DAI'group by 1, 2),total_volume_and_users_per_bucket as (selecttrade_size,sum(volume) as total_vol_per_bucket,sum(user_count) as total_users_per_bucketfrom bucketed_datagroup by trade_size),percentage_data as (selecta.trade_size,a.frontend,a.tx_count,a.volume,a.user_count,a.volume / b.total_vol_per_bucket * 100 as volume_percentage,a.user_count / b.total_users_per_bucket * 100 as user_percentagefrom bucketed_data ajoin total_volume_and_users_per_bucket b on a.trade_size = b.trade_size)selecttrade_size,casewhen volume_percentage < 1 and user_percentage < 1 then 'Other'else frontendend as grouped_frontend,sum(tx_count) as tx_count,sum(volume) as volume,sum(user_count) as user_count,sum(volume_percentage) as volume_percentage,sum(user_percentage) as user_percentagefrom percentage_datagroup by 1,2order by 1,2