Popex404weekday contracts near #1
    Updated 2023-01-19
    -- From the sample Dashboard of Brianterra https://app.flipsidecrypto.com/dashboard/near-transparency-report-12-15-fxcrlG
    -- Credits to Adriaparcerisas too https://app.flipsidecrypto.com/dashboard/near-transparency-report-C_p0q9

    with NewContract as (
    SELECT
    trunc(first_date,'day') as date1,
    count(distinct receiver_id ) as new_contracts,
    sum(new_contracts) over (order by date1) as cum_new_contracts
    from (select
    receiver_id,
    min(x.block_timestamp) as first_date
    from near.core.fact_actions_events x
    join near.core.fact_receipts y on x.tx_hash=y.tx_hash
    where action_name = 'DeployContract'
    group by 1) where first_date between '2023-01-01' and '2023-01-17'
    group by 1
    order by 1 asc
    ),
    ActiveContract as (
    SELECT
    date_trunc('day', call.block_timestamp) as date2,
    COUNT(DISTINCT tr.TX_RECEIVER) as smart_contracts
    FROM near.core.fact_actions_events_function_call call
    INNER JOIN near.core.fact_transactions tr
    ON call.TX_HASH = tr.TX_HASH
    INNER JOIN near.core.fact_receipts as rc
    ON tr.TX_HASH=rc.TX_HASH
    WHERE ACTION_NAME = 'FunctionCall'
    AND METHOD_NAME <> 'new'
    AND date2 between '2023-01-01' and '2023-01-17'
    group by 1
    )
    select case
    when dayname(date2) = 'Mon' then 'a Monday'
    when dayname(date2) = 'Tue' then 'b Tuesday'
    Run a query to Download Data