0-MIDdis age time
    Updated 2023-01-03
    with act1 as (
    with tab1 as (
    select SWAP_PROGRAM,SWAPPER
    from algorand.defi.fact_swap
    where BLOCK_TIMESTAMP>=current_date-{{Last_x_Days}}),
    tab2 as (
    select ADDRESS,CREATED_AT
    from algorand.core.dim_account)
    select SWAP_PROGRAM,SWAPPER,datediff(day,CREATED_AT,current_date)as wallet_age
    from tab1
    left join tab2
    on tab1.SWAPPER=tab2.ADDRESS)
    select SWAP_PROGRAM
    ,case
    when wallet_age>0 and wallet_age<=30 then 'Below 1 Month'
    when wallet_age>30 and wallet_age<=90 then '1 ~ 3 Months'
    when wallet_age>90 and wallet_age<=180 then '3 ~ 6 Months'
    when wallet_age>180 and wallet_age<=365 then '6 Months ~ 1 Year'
    when wallet_age>365 then 'Up to 1 Year' end as dis_time
    ,count(distinct SWAPPER) as swapper_count
    from act1
    where dis_time is not null
    group by 1,2

    Run a query to Download Data