Query editor
with diario as (-- Ășltimo snapshot de cada dia, por mercadoselectcast(snapshot_ts as date) as dia,symbol,open_interest_usd,row_number() over (partition by cast(snapshot_ts as date), symbolorder by snapshot_ts desc) as nfrom dune.theosq.lighter_markets_dailywhere status = 'active'),top8 as (-- os 8 maiores mercados no dia mais recenteselect symbolfrom diariowhere n = 1 and dia = (select max(dia) from diario)order by open_interest_usd desclimit 8)selectd.dia,case when t.symbol is not null then d.symbol else 'Outros' end as mercado,sum(d.open_interest_usd) as open_interest_usdfrom diario dleft join top8 t on t.symbol = d.symbolwhere d.n = 1group by 1, 2order by 1, 3 desc