nitsMost Time Taking Events
    Updated 2022-12-13
    with events as (SELECT event_type, block_height as bh FROM flow.core.fact_events ),
    f as
    (
    SELECT block_timestamp as bt , block_height as bn from flow.core.fact_blocks),
    flow as
    ( SELECT event_type, avg(td) as avg_time_taken, 'flow' as type
    from
    (SELECT * from
    ( SELECT *
    , timestampdiff(sql_tsi_second,bt, block_timestamp) as td
    from f
    inner join flow.core.fact_blocks
    on block_height = bn +1 )
    join events on bh = bn)
    where date(block_timestamp)>= '{{start_date}}'
    GROUP by 1 )
    SELECT * from flow
    order by 2 desc
    -- LIMIT 100
    Run a query to Download Data