mattkstewTerradash 1
    Updated 2022-12-20
    with tab1 as (
    select
    min(date_trunc('week', block_timestamp)) as date1,
    message_value:contract
    from terra.core.ez_messages
    where message_type like '%Contract%'
    group by 2
    )
    , tab2 as
    (
    select
    date1,
    count(*) as amount
    from tab1
    group by 1
    )

    , tab3 as
    (
    select
    date1,
    (sum(amount) Over (Order by date1)) as moving_total
    from tab2

    )

    select *

    from tab2 left outer join tab3 on tab2.date1 = tab3.date1
    Run a query to Download Data