mattkstewIn The News, Wallets 2
    Updated 2023-01-06
    with tab1 as (
    select
    date_trunc('day', block_timestamp) as date1,
    count(*) as created


    from near.core.fact_actions_events
    where action_name in ('CreateAccount')
    and date1 > current_date - 60
    group by 1 )

    , tab2 as (
    select
    date_trunc('day', block_timestamp) as date2,
    count(*) as deleted


    from near.core.fact_actions_events
    where action_name in ('DeleteAccount')
    and date2 > current_date - 60
    group by 1 )


    select
    date1,
    case when date1 >= '2023-01-01' then '2023' else '2022' end as Year_to_date,
    created - deleted

    from tab1 left outer join tab2 on date1 = date2
    Run a query to Download Data