with programs_jan as (
SELECT
PROGRAM_ID,
(BLOCK_TIMESTAMP) as first_day
FROM
solana.core.fact_events JOIN solana.core.dim_labels
ON solana.core.fact_events.PROGRAM_ID = solana.core.dim_labels.address
WHERE
BLOCK_TIMESTAMP::DATE >= '2022-06-01'
AND
BLOCK_TIMESTAMP::DATE <= '2022-06-30'),
programs_3_month as (
SELECT
PROGRAM_ID,
(BLOCK_TIMESTAMP) as first_day
FROM
solana.core.fact_events JOIN solana.core.dim_labels
ON solana.core.fact_events.PROGRAM_ID = solana.core.dim_labels.address
WHERE
BLOCK_TIMESTAMP::DATE >= '2022-04-01'),
programs_2022_avg as (
SELECT
COUNT(PROGRAM_ID) / 90 as avg_3
FROM
programs_3_month
),
final_query as (
SELECT
DATE_TRUNC('day',first_day ) as main_time,
COUNT (PROGRAM_ID) as unique_programs