subiniumnear new user
    Updated 2024-04-03
    -- forked from 6f0e9f2d-b84d-45d9-8d8a-41d8a2009375

    with first_time as (
    SELECT
    TX_SIGNER,
    MIN(block_timestamp) as first_time
    FROM near.core.fact_transactions
    GROUP BY 1
    ),
    new_user as (
    SELECT
    date_trunc('month', first_time) as month,
    COUNT(TX_SIGNER) as new
    FROM first_time
    GROUP BY 1
    ),
    total_user as (
    SELECT
    date_trunc('month', block_timestamp) as month,
    COUNT(distinct TX_SIGNER) as mau
    FROM near.core.fact_transactions
    GROUP BY 1)

    SELECT
    month,
    mau,
    new,
    sum(new) over(order by month asc) as total_address,
    mau-new as old
    FROM total_user t
    LEFT JOIN new_user n using(month)



    QueryRunArchived: QueryRun has been archived