pinehearstNEAR City - Active Wallets Over time
Updated 2022-12-16Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with wallet_age AS (
SELECT
tx_signer as address,
count(distinct tx_hash) as tx_counts,
count(distinct date(block_timestamp)) as days_active,
min(date(block_timestamp)) as first_tx,
max(date(block_timestamp)) as last_tx,
datediff('day', last_tx, getdate()) as days_last_active,
datediff('day', first_tx, getdate()) as age_today
from near.core.fact_transactions
group by 1
),
new_users_stat AS (
SELECT
first_tx,
count(distinct address) as new_users,
count(distinct case when days_active >= 7 AND days_last_active <= 7 then address else null end) as active_user,
count(distinct case when days_active >= 2 then address else null end) as active_two_days,
count(distinct case when days_active >= 7 then address else null end) as active_one_week,
count(distinct case when days_active >= 28 then address else null end) as active_one_month
FROM wallet_age
GROUP BY 1
)
SELECT
first_tx,
new_users as "New Wallets",
active_user as "New Active Users",
case when current_date - date(first_tx) < 30 then first_tx else null end as last_month,
sum(new_users) over (order by last_month) as "New Wallets Last 30Days",
sum(new_users) over (order by first_tx) as "Cumulative New Wallets",
sum(active_user) over (order by first_tx) as "Cumulative Active Users",
sum(active_two_days) over (order by first_tx) as "Active > 2 Day",
sum(active_one_week) over (order by first_tx) as "Active > 1 Week",
sum(active_one_month) over (order by first_tx) as "Active > 1 Month"
FROM new_users_stat
ORDER BY 1 DESC
Run a query to Download Data