Query editor
with pnl_table as (select sum(daily_pnl) over (order by day) as total_pnl, coalesce(daily_pnl,0) as daily_pnl, coalesce(profit,0) as profit, coalesce(loss, 0) as loss, dayfrom (select sum(trade_pnl) * -1 as daily_pnl, sum(trade_pnl) filter (where trade_pnl < 0) * -1 as profit, sum(trade_pnl) filter (where trade_pnl > 0) * -1 as loss, dayfrom query_2427066group by day)), fee_table as (select sum(daily_fee) over (order by day) as total_fees, * from (select sum(fee) as daily_fee, dayfromquery_2390745group by day))select pt.*, daily_fee, total_feesfrom pnl_table ptleft join fee_table ft on pt.day = ft.day