granadohoAverage Time Between Blocks
    Updated 2022-01-20
    WITH table1 as (
    select
    t1.block_id as block_id,
    LAG(t1.timestamp, 1) OVER(ORDER BY block_id) AS start_time,
    t1.timestamp as end_time,
    TIMESTAMPDIFF(SECOND, LAG(t1.timestamp, 1) OVER(ORDER BY block_id), t1.timestamp) AS SECONDDIFFERENCE
    from (
    SELECT
    block_id ,max(block_timestamp) AS timestamp
    FROM algorand.block
    GROUP BY block_id
    ORDER BY timestamp ASC
    ) t1
    )

    SELECT
    avg(table1.SECONDDIFFERENCE) as average_time_between_blocks
    from table1
    Run a query to Download Data