elsina2024-08-20: Age wallet
    Updated 2024-10-19
    with t1 as (
    SELECT
    origin_from_address as user,
    min(block_timestamp) as min_swap_tx
    from
    avalanche.defi.ez_dex_swaps
    group by user
    ),

    t2 as (
    SELECT
    user,
    min_swap_tx,
    min(block_timestamp) as min_tx
    from
    avalanche.core.fact_transactions b left join t1 a on user = from_address
    group by
    user, min_swap_tx
    ),

    t3 as (
    select
    user,
    datediff('day' , min_tx , min_swap_tx) as age_wallets
    from t2
    )
    select
    case
    when age_wallets < 1 then 'A : < 1 days'
    when age_wallets < 10 then 'B : < 1-10 days'
    when age_wallets < 30 then 'C : < 10-30 days'
    when age_wallets < 90 then 'D : < 30-90 days'
    when age_wallets < 180 then 'E : < 90-180 days'
    when age_wallets < 365 then 'F : < 180-365 days'
    else 'G : over 1 year'
    QueryRunArchived: QueryRun has been archived