messariklaytn_daily_addresses
    Updated 2024-10-15
    -- forked from Eman-Raz / klaytn users @ https://flipsidecrypto.xyz/Eman-Raz/q/TymnkArLCxcK/klaytn-users

    with tab1 as (select date_trunc('day',block_timestamp) as "Date", count(distinct from_address) as "Total Users"
    from kaia.core.fact_transactions
    where tx_succeeded='true'
    group by 1),

    tab2 as (with tab10 as (select from_address, min(block_timestamp::date) as first_tx
    from kaia.core.fact_transactions
    where tx_succeeded='true'
    group by 1)

    select date_trunc('day',first_tx) as "Date", count(distinct from_address) as "New Users"
    from tab10
    group by 1)

    select tab1."Date" as "Date", "Total Users" as "total_address", "New Users" as "new_address", "Total Users"-"New Users" as "active_address"
    from tab1 left join tab2 on tab1."Date"=tab2."Date"
    where tab1."Date" >= '2023-01-01'



    QueryRunArchived: QueryRun has been archived