pouria-sharifzadGnosis Active Wallets By day
    Updated 2022-07-30
    with base_wallets as (
    SELECT
    COUNT(*) as txns,
    from_address as wallet,
    MAX(DATEADD('day', 90, date_trunc('day', block_timestamp))) as ddate_ul,
    date_trunc('day', block_timestamp) as ddate
    from gnosis.core.fact_transactions
    GROUP BY ddate, wallet
    ),

    dates as (
    SELECT
    -- first argument is unit of time to add, second is amount to increment, third is starting date
    dateadd(day, '-' || row_number() over (order by null), current_date() + 1) as date
    from table (generator(rowcount => 275))
    ),

    mixer as (
    SELECT
    d.date,
    b.wallet,
    b.ddate,
    b.ddate_ul
    from dates d
    INNER JOIN base_wallets b ON d.date<=ddate_ul AND d.date>=b.ddate
    )

    SELECT
    date,
    COUNT(DISTINCT wallet) as active_wallets
    from mixer
    GROUP BY date ORDER BY date ASC
    Run a query to Download Data