namanasyncTotal new Users copy
    Updated 2024-08-30
    -- forked from hess / Total new Users @ https://flipsidecrypto.xyz/hess/q/u1cqBoG6BJOY/total-new-users

    with new_dai as ( select min(block_timestamp) as min , from_address
    from ethereum.core.fact_transactions
    where tx_hash in (select tx_hash from ethereum.core.ez_token_transfers
    where symbol = 'DAI')
    group by 2)
    ,
    new_usdc as ( select min(block_timestamp) as min , from_address
    from ethereum.core.fact_transactions
    where tx_hash in (select tx_hash from ethereum.core.ez_token_transfers
    where symbol = 'USDC')
    group by 2)
    ,
    new_usdt as ( select min(block_timestamp) as min , from_address
    from ethereum.core.fact_transactions
    where tx_hash in (select tx_hash from ethereum.core.ez_token_transfers
    where symbol = 'USDT')
    group by 2)
    ,
    final as ( select 'New DAI Users' as type, trunc(min,'month') as monthly , count(DISTINCT(from_address)) as total_user, sum(total_user) over (order by monthly asc) as cumulative_new
    from new_dai
    where monthly >= '2022-01-01'
    group by 1,2
    UNION
    select 'New USDC Users' as type, trunc(min,'month') as monthly , count(DISTINCT(from_address)) as total_user, sum(total_user) over (order by monthly asc) as cumulative_new
    from new_usdc
    where monthly >= '2022-01-01'
    group by 1,2
    UNION
    select 'New USDT Users' as type, trunc(min,'month') as monthly , count(DISTINCT(from_address)) as total_user, sum(total_user) over (order by monthly asc) as cumulative_new
    from new_usdt
    where monthly >= '2022-01-01'
    group by 1,2)

    select type, avg(total_user) as avg_user, sum(total_user) as total_users
    QueryRunArchived: QueryRun has been archived