with new_users as(select
date_trunc('day', first_transaction_stamp) as first_transaction_date,
sender,
n_transactions
from (
select
msg_value:sender::string as sender,
min(block_timestamp) as first_transaction_stamp,
count(tx_id) as n_transactions
from terra.msgs
WHERE msg_value:contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s' --anchor
AND block_timestamp >= CURRENT_DATE - 300
group by 1)
where first_transaction_date >= CURRENT_DATE - 90),
histogram as (select n_transactions
from new_users)
select floor(n_transactions/1)*1 as bin_floor, count(*) as N
from histogram
where n_transactions <= 20
group by 1
order by 1