Afonso_DiazGrouping users by active days
    Updated 2025-01-05
    with

    main as (
    select
    tx_hash,
    block_timestamp,
    from_address as user,
    tx_fee
    from
    mantle.core.fact_transactions
    where
    tx_succeeded
    and block_timestamp::date between '{{ start_date }}' and '{{ end_date }}'
    ),

    users as (
    select
    user,
    count(distinct tx_hash) as transactions,
    count(distinct block_timestamp::date) as active_days
    from
    main
    group by 1
    )

    select
    case
    when active_days <= 7 then 'a. 1 days - 1 week'
    when active_days <= 14 then 'b. 1 week - 2 weeks'
    when active_days <= 30 then 'c. 2 weeks - 1 month'
    when active_days <= 90 then 'd. 1 month - 3 months'
    when active_days <= 180 then 'e. 3 months - 6 months'
    when active_days <= 364 then 'f. 6 months - 1 year'
    else 'g. > 1 year'
    end as type,
    count(distinct user) as users
    QueryRunArchived: QueryRun has been archived