MadiAvg Block Time
    Updated 2023-03-14
    with block_time as (
    select BLOCK_ID, block_timestamp ,lag(block_timestamp,1) over(order by block_timestamp) as block_timestamp_lag,
    timediff(second, block_timestamp_lag, block_timestamp) as block_timediff
    from terra.core.fact_blocks
    order by block_timestamp
    )

    select date_trunc('week', block_timestamp),
    avg(block_timediff) as avg_block_time,
    max(block_timediff) as max_block_time,
    min(block_timediff) as min_block_time
    from block_time
    where BLOCK_ID in (SELECT DISTINCT BLOCK_ID from terra.core.fact_transactions where TX_SUCCEEDED = 'TRUE')
    group by 1 order by 1 desc
    Run a query to Download Data