Query editor
with base as (selecttoken_mint_address,sum(token_balance) as token_balancefrom query_3927516where usd_vol is nullgroup by 1--and user = '{{wallet_address}}'),base_2 as (select sum(usd_vol_1 + usd_vol_2) as usd_volfrom (select sum(usd_vol) as usd_vol_1from query_3927516where usd_vol is not null--and user = '{{wallet_address}}') a,(select sum(usd_balance) as usd_vol_2from query_3927515--where user = '{{wallet_address}}')b),dex_Data AS (SELECTblock_time,-- user,token_mint_address,token_balance,-- case-- when token_sold_symbol is null then token_sold_mint_address-- else token_sold_symbol-- end as token,-- amount_usd as usd_volume,-- 0 as latest_price,(amount_usd / coalesce(token_sold_amount,0)) as tpFROMdex_solana.trades dright join base b on b.token_mint_address = d.token_sold_mint_addressWHEREblock_time >= timestamp '2024-01-01'UNION ALLSELECTblock_time,-- user,token_mint_address,token_balance,-- case-- when token_bought_symbol is null then token_bought_mint_address-- else token_bought_symbol-- end as token,-- - amount_usd as usd_volume,-- amount_usd / token_bought_amount as latest_price,(amount_usd / coalesce(token_bought_amount,0)) as tpFROMdex_solana.trades dright join base b on b.token_mint_address = d.token_bought_mint_addressWHEREblock_time >= timestamp '2024-01-01'),