Updated 2024-08-07
    -- forked from Masi / Avg Nwe Users 2024 @ https://flipsidecrypto.xyz/Masi/q/jrbuo9qR1VWh/avg-nwe-users-2024

    with tb1 as ( select block_timestamp,
    tx_signer as user
    from near.core.fact_transactions
    where TX_SUCCEEDED = 'true'
    UNION
    select block_timestamp,
    tx_receiver as user
    from near.core.fact_transactions
    where TX_SUCCEEDED = 'true'
    )
    ,
    tb2 as ( select min(block_timestamp) as min,
    user
    from tb1
    group by 2)
    ,
    tb3 as (select trunc(min,'day') as daily,
    count(DISTINCT user) as users,
    sum(users) over (order by daily asc) as cumulative_users
    from tb2
    where min::date >= '2022-10-01'
    and user not in (select address from near.core.dim_address_labels)
    group by 1 )

    select avg(users) as avg_users,
    sum(users) as total_users
    from tb3
    where daily >= '2024-01-01'




    QueryRunArchived: QueryRun has been archived