crypto_king3New_Users
    Updated 2024-11-13
    with t as (
    select
    from_address as user,
    min(block_timestamp::date) as created_at
    from avalanche.core.fact_transactions
    where to_address = lower('0xB8d7710f7d8349A506b75dD184F05777c82dAd0C')
    group by from_address
    ),

    t2 as (
    select
    created_at as day,
    count(distinct user) as new_users
    from t
    group by created_at
    ),

    t3 as (
    select
    block_timestamp::date as day,
    count(distinct from_address) as total_users
    from avalanche.core.fact_transactions
    where to_address = lower('0xB8d7710f7d8349A506b75dD184F05777c82dAd0C')
    group by block_timestamp::date
    ),

    -- Calculating the cumulative metrics
    metrics as (
    select
    t3.day,
    total_users,
    coalesce(t2.new_users, 0) as new_users,
    sum(coalesce(t2.new_users, 0)) over (order by t3.day) as cumulative_new_users
    from t3
    left join t2 on t3.day = t2.day
    )
    QueryRunArchived: QueryRun has been archived