Query editor
withusd_table as (select symbol,price from prices.usd_latestwhere symbol = 'ETH' order by minute desc limit 1), eth_gas_used as (select date_trunc('day', block_time) as Date, sum(gas_used) as gas_usedfrom ethereum.transactionswhere date_trunc('day', block_time) >= NOW() - INTERVAL '30' DAYgroup by 1 order by 1), arb_gas_used as (select date_trunc('day', block_time) as Date, sum(gas_used - gas_used_for_l1) as gas_usedfrom arbitrum.transactionswhere date_trunc('day', block_time) >= NOW() - INTERVAL '30' DAYgroup by 1 order by 1),op_gas_used as (select date_trunc('day', block_time) as Date, sum(gas_used) as gas_usedfrom optimism.transactionswhere date_trunc('day', block_time) >= NOW() - INTERVAL '30' DAYgroup by 1 order by 1)select a.Date,a.gas_used as "Total gas used ARB",ROUND(AVG(a.gas_used)OVER(order by a.Date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW), 2) as "Rolling Average ARB 7 days",e.gas_used as "Total gas used ETH",ROUND(AVG(e.gas_used)OVER(order by a.Date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW), 2) as "Rolling Average ETH 7 days",o.gas_used as "Total gas used OP",ROUND(AVG(o.gas_used)OVER(order by a.Date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW), 2) as "Rolling Average OP 7 days"from arb_gas_used a, eth_gas_used e, op_gas_used owhere a.Date = e.Date and a.Date = o.Date order by 1