0-MIDhold time dis
    Updated 2023-05-09
    with tab1 as (
    select min(DATE) as mindate, ADDRESS
    from osmosis.core.fact_daily_balances
    where currency = 'uosmo'
    group by 2),
    tab2 as (
    select DATE as today,ADDRESS
    from osmosis.core.fact_daily_balances
    where DATE=current_date
    group by 1,2)
    select datediff(day,mindate,today)as hold_time,count(distinct tab2.address)as users
    ,case
    when hold_time>1 and hold_time<=10 then '1 DAY ~ 10 DAY'
    when hold_time>10 and hold_time<=30 then '10 DAY ~ 1 MONTH'
    when hold_time>30 and hold_time<=60 then '1 MONTH ~ 3 MONTHS'
    when hold_time>60 and hold_time<=90 then '3 MONTHS ~ 6 MONTHS'
    when hold_time>90 and hold_time<=180 then '6 MONTHS ~ 9 MONTHS'
    when hold_time>180 and hold_time<=365 then '9 MONTHS ~ 1 YEAR'
    when hold_time>365 then 'UP TO 1 YEAR' end as hold_dis
    from tab1
    left join tab2
    on tab1.ADDRESS=tab2.ADDRESS
    where hold_time>0
    and hold_time is not null
    and hold_dis is not null
    group by 1



    Run a query to Download Data