select
date_trunc('day', a.block_timestamp) as date,
avg(datediff(second,a.block_timestamp, b.block_timestamp)) as Avg_block_time
from mezo.testnet.fact_blocks a, mezo.testnet.fact_blocks b
where
a.block_number = b.block_number - 1 and
date is not null
group by 1