Moechain 3
    Updated 2024-05-29
    with t1 as (
    SELECT
    TIMESTAMP,
    CONTRACT as user
    from external.tokenflow_starknet.decoded_transactions
    ),


    t3 as (
    select
    user as user1,
    min(date_trunc('month',TIMESTAMP)) as first_txn
    from (
    select * from t1
    )
    group by user1
    ),

    t4 as (
    select month, user
    from (
    select date_trunc('month',TIMESTAMP) as month, user from t1
    )
    group by month, user
    )


    select
    month,
    user_type,
    count(distinct user) as no_users
    from (
    select month, first_txn, user1, user,
    case
    when datediff('month',first_txn,month)=0 then 'New user'
    QueryRunArchived: QueryRun has been archived