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
)
, tab2 as (
select
date1,
count(*) as value
from tab1
where date1 > current_date - 60
group by 1
order by 1
)
SELECT
avg(value)
from tab2