select
date_trunc('hour',block_timestamp) as hour,
avg(gas_price) as avg_gas,
avg(avg_gas) over (order by hour rows between 6 preceding and current row) as "6 hour average gas price",
avg(fee_usd) as avg_fee,
avg(avg_fee) over (order by hour rows between 6 preceding and current row) as "6 hour average fees paid"
from ethereum.transactions
where block_timestamp >= getdate() - interval '30 days'
group by 1
order by 1