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
date_trunc('day', date1) as date_day,
count(*) as amount
from tab1
group by 1 )
select
date_day as date1,
sum(amount) Over (order by date_day) as value
from tab2
order by 1