mattkstewnothing atm1
    Updated 2023-01-17
    with tab1 as (
    select
    message_value:contract,
    min(BLOCK_TIMESTAMP) as date1


    from terra.core.ez_messages
    where message_type like '%Contract%'
    group by 1
    )

    select
    date_trunc('day', date1) as date1,
    case when date1 > '2022-12-01' then '2023'
    else '2022'
    END as Year_to_date,
    count(*) as value
    from tab1
    --where date1 > current_date - 180
    group by 1,2
    order by 1

    -- find average amount normally compared to rn.
    Run a query to Download Data