Afonso_DiazRetention Rate
Updated 2024-08-05
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 pricet as (
select
hour::date as date,
avg(price) as price_usd
from near.price.ez_prices_hourly
where token_address = 'wrap.near'
group by 1
),
main as (
select
tx_hash,
block_timestamp,
signer_id as user,
amount,
action,
amount * price_usd as amount_usd
from near.gov.fact_staking_actions
left join pricet on date = block_timestamp::date
where action = 'staking'
),
user_activity AS (
SELECT
user,
date_trunc('month', block_timestamp) AS date_start
FROM main
GROUP BY user, date_start
)
SELECT
a.date_start AS start_date,
COUNT(DISTINCT a.user) AS active_users,
COUNT(DISTINCT b.user) AS retained_users,
(COUNT(DISTINCT b.user) * 100.0 / COUNT(DISTINCT a.user)) AS retention_rate
FROM user_activity a
QueryRunArchived: QueryRun has been archived