Query editor
with sums as (select block_date,casewhen token_pair is null and u.pair is not null then u.pairwhen token_pair is null and u.pair is null then 'OTHER'else token_pair end as pair,sum(amount_usd) as daily_pair_sumfrom xchange.trades t left join query_2971185 u on t.project_contract_address=u.addresswhere block_date >= timestamp '2023-06-01'group by block_date,casewhen token_pair is null and u.pair is not null then u.pairwhen token_pair is null and u.pair is null then 'OTHER'else token_pair end),raw as (selectcasewhen token_pair is null and u.pair is not null then u.pairwhen token_pair is null and u.pair is null then 'OTHER'else token_pair end as pair,t.*from xchange.trades t left join query_2971185 u on t.project_contract_address=u.addresswhere block_date >= timestamp '2023-06-01')select r.*, s.daily_pair_sumfrom sums s inner join raw r on s.pair=r.pair and s.block_date=r.block_date