K41R0Naleo - 3 copy
    Updated 2025-01-09
    -- forked from jackguy / aleo - 3 @ https://flipsidecrypto.xyz/jackguy/q/ub-noxklNNSy/aleo---3

    with tab1 as (
    SELECT
    date(block_timestamp) as date,
    count(DISTINCT TRIM(SPLIT_PART(SPLIT_PART(fee_msg['transition']['outputs'][0]['value'], '[', 2), ',', 1))) as active_wallets
    from aleo.core.fact_transactions
    where tx_succeeded
    GROUP BY 1
    ), tab2 as (
    SELECT
    day,
    count(*) as new_wallets,
    sum(new_wallets) over (ORDER by day) as total_wallets
    from (
    SELECT
    TRIM(SPLIT_PART(SPLIT_PART(fee_msg['transition']['outputs'][0]['value'], '[', 2), ',', 1)) as wallet,
    min(date(block_timestamp)) as day
    from aleo.core.fact_transactions
    where tx_succeeded
    GROUP BY 1
    )
    group by 1
    )

    SELECT
    *,
    active_wallets - new_wallets as returning_wallets

    from tab1
    left outer join tab2
    QueryRunArchived: QueryRun has been archived