Flipside Teamnear users
    Updated 2024-10-17
    with
    txs as (
    select BLOCK_TIMESTAMP,
    TX_SIGNER,
    TX_RECEIVER
    from near.core.fact_transactions),

    receipts as (
    select BLOCK_TIMESTAMP, RECEIVER_ID
    from near.core.fact_receipts),


    users_txs as (
    select BLOCK_TIMESTAMP, TX_SIGNER as user
    from txs
    union all
    select BLOCK_TIMESTAMP, TX_RECEIVER
    from txs
    union all
    select BLOCK_TIMESTAMP, RECEIVER_ID
    from receipts),
    users as (
    select user, min(BLOCK_TIMESTAMP) as min_date
    from users_txs
    group by 1)

    select date_trunc(day, min_date) as "Date", count(distinct user) as "Wallets",
    sum("Wallets") over (order by "Date") as "Total Wallets"
    from users
    where "Date" is not null
    group by 1

    QueryRunArchived: QueryRun has been archived