select
date as "Month",
txn as "Transactions",
users as "Active Users",
avg(txn) over (order by date rows between 5 preceding and current row ) as "5MA",
sum(txn) over(order by date asc) as "Cumulative txs",
"Transactions"/"Active Users" as "txs per user"
from
(
select
date_trunc('month',block_timestamp) as date,
count(distinct tx_id) as txn,
count(distinct proposer) as users
from
flow.core.fact_transactions
where
tx_succeeded = true
group by
date
)
order by
"Month"