with
A as ( select date, protocol,
sum(fees) over (partition by protocol order by date) as "Total Fees",
sum(revenue) over (partition by protocol order by date) as "Total Revenue",
sum(fees - revenue) over (partition by protocol order by date) as "Total Fees Contribute To Ethereum"
from external.defillama.fact_protocol_fees_revenue
where protocol in ('Optimism','Arbitrum') )
select *
from A