Updated 2022-08-03
    with deployed_smart_contracts as
    (
    select RECEIVER_ID as contract_name
    ,e.TX_HASH
    ,e.BLOCK_TIMESTAMP::date contract_creation_date
    from near.core.fact_actions_events as e
    join near.core.fact_receipts as r
    on e.TX_HASH=r.TX_HASH
    where ACTION_NAME='DeployContract'
    and STATUS_VALUE like '%Success%'
    and e.block_timestamp >=
    CASE lower({{please_select_time_period?}})
    WHEN 'last_day' THEN DATEADD(day,-1,CURRENT_DATE)
    WHEN 'last_week' THEN DATEADD(day,-7,CURRENT_DATE)
    WHEN 'last_month' THEN DATEADD(day,-30,CURRENT_DATE)
    WHEN 'last_3_month' THEN DATEADD(day,-90,CURRENT_DATE)
    WHEN 'year_2022' THEN '2022-01-01'
    WHEN 'overall' THEN '2018-01-01'
    ELSE '2022-01-01'
    END
    )

    select contract_creation_date,
    count(distinct TX_HASH) as daily_number_of_deployed_contracts,
    sum(daily_number_of_deployed_contracts) over (order by contract_creation_date rows between unbounded preceding and current row ) as cumulative_daily_number_of_deployed_contracts
    from deployed_smart_contracts
    group by contract_creation_date
    order by contract_creation_date

    Run a query to Download Data