with time as (select trunc(a.block_timestamp,'hour') as hourly,
avg(datediff(second,a.block_timestamp, b.block_timestamp)) as avg_time
from aptos.core.fact_blocks a, aptos.core.fact_blocks b
where a.BLOCK_NUMBER = b.BLOCK_NUMBER-1
and a.block_timestamp::Date >= current_date - 1
group by 1 )
select avg(avg_time) as "Avg Block Time"
from time