Query editor
with latest as (select *from dune.blees_eth.dataset_hyperliquid_hip4_marketswhere snapshot_time_utc = (select max(snapshot_time_utc)from dune.blees_eth.dataset_hyperliquid_hip4_markets)),markets as (selectoutcome_id,max(market_name) as market_name,max(underlying) as underlying,max(expiry) as expiry,max(target_price) as target_price,max(period) as period,-- Sum side volumes, because each market has Yes/No side rowssum(cast(side_contract_volume as double)) as market_volume,sum(cast(side_trade_count as bigint)) as market_trades,sum(cast(side_approx_notional as double)) as market_approx_notionalfrom latestgroup by outcome_id)select'TOTAL' as row_type,cast(null as varchar) as outcome_id,cast(null as varchar) as market_name,cast(null as varchar) as underlying,cast(null as varchar) as expiry,cast(null as varchar) as target_price,cast(null as varchar) as period,sum(market_volume) as volume,sum(market_trades) as trades,sum(market_approx_notional) as approx_notionalfrom marketsunion allselect'MARKET' as row_type,cast(outcome_id as varchar) as outcome_id,market_name,underlying,expiry,cast(target_price as varchar) as target_price,period,market_volume as volume,market_trades as trades,market_approx_notional as approx_notionalfrom marketsorder bycase when row_type = 'TOTAL' then 0 else 1 end,volume desc;