select
(sum(gas_limit/pow(10,9)) * avg(price_usd))/count(distinct BLOCK_HEIGHT) as Fee_per_block
from flow.core.fact_transactions inner join flow.core.fact_prices p
on timestamp::date = block_timestamp::date and hour(p.timestamp) = hour(block_timestamp)
where block_timestamp > CURRENT_DATE - 31
and token = 'Flow'
and tx_succeeded = 'TRUE'