with t as (
select
user_address as users,
LAST_ACTIVITY_BLOCK_TIMESTAMP::date as last_date
from ethereum.core.ez_current_balances
where
SYMBOL = 'DYDX'
group by 1,2
-- contract_address = '0x92d6c1e31e14520e676a687f0a93788b716beff5'
)
select
date_trunc(month, last_date) as date,
case when date >= '2021-01-01' and date < '2022-01-01' then '2021'
when date >= '2022-01-01' and date < '2023-01-01' then '2022'
else '2023' end as years,
count(users) as total_users_active
from t
group by 1,2