kiacryptoBlock time, TPB
    Updated 2023-01-11
    with block as (
    select block_timestamp,
    lead(block_timestamp) over(order by block_id) as next_block_time,
    datediff('s',block_timestamp,next_block_time) as diff,
    tx_count
    from near.core.fact_blocks
    ),
    info as (
    select
    date_trunc('day', block_timestamp) as "Day",
    avg(diff) as "block time",
    avg(tx_count) as "TPB"
    from block
    where "Day" between '2022-07-01' and '2022-09-30'
    group by 1
    ),
    avg_info as (
    select
    avg("block time") as "AVG block time",
    avg("TPB") as "AVG TPB"
    from info
    )
    select *
    from info, avg_info
    order by "Day"
    Run a query to Download Data