with tab1 as (
select
date_trunc('week',block_timestamp) as date,
case
when date >= '2022-01-01' and date < '2022-12-18' then 'other days'
when date >= '2022-12-18' and date <= '2023-01-03' then 'holidays'
end as time_frame,
count(distinct tx:body:messages[0]:contract) as Active_contract
from terra.core.fact_transactions
where tx_succeeded = 'TRUE'
and date <= '2023-01-03'
group by 1,2)
select
time_frame,
avg(active_contract) as avg_contract
from tab1
group by 1