SELECT
date_trunc('day',a.block_timestamp) as date,
Avg(DATEDIFF(SECOND, a.block_timestamp, b.block_timestamp)) as avg_between_block_time
FROM polygon.core.fact_blocks a
JOIN polygon.core.fact_blocks b
on a.BLOCK_NUMBER = b.BLOCK_NUMBER - 1
where a.block_timestamp >= CURRENT_DATE-30
group by date
order by date