-- Tarik - revised from query by ben_milliam https://app.flipsidecrypto.com/velocity/queries/e7477a28-bb86-46a7-a4c1-c1cb49874923
with tmp as (SELECT
date,
address,
sum(balance)
FROM terra.daily_balances
WHERE balance_type = 'staked' and currency = 'LUNA'
and date::date >= CAST('2021-01-01' as Date)
group by date, address
having sum(balance) > 0
)
select
date,
count(distinct address)
from tmp
group by 1
order by date asc;