Query editor
WITH weekly_pool_fees AS (SELECT DATE_TRUNC('week', day) AS week,ticker,pool,pool_address,SUM(total_pool_fees) AS total_pool_feesFROM query_5956224GROUP BY 1,2,3,4ORDER BY week DESC, total_pool_fees DESC)SELECT *,SUM(total_pool_fees) OVER (PARTITION BY week ORDER BY total_pool_fees) AS weekly_protocol_fees,SUM(total_pool_fees) OVER (ORDER BY week) AS protocol_cumulative_feesFROM weekly_pool_feesORDER BY week DESC, total_pool_fees DESC