thejoycehuman-gold
Updated 2024-09-06
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 user_activity AS (
SELECT
payer AS user,
COUNT(DISTINCT tx_id) AS total_transactions
FROM
flow.core.fact_transactions
WHERE
block_timestamp BETWEEN DATEADD(day, -30, CURRENT_DATE()) AND CURRENT_DATE()
GROUP BY
payer
),
active_users AS (
SELECT
user
FROM
user_activity
WHERE
total_transactions > 1
),
new_users AS (
SELECT
user
FROM
user_activity
WHERE
total_transactions = 1
),
metrics AS (
SELECT
COUNT(DISTINCT ua.user) AS total_users,
COUNT(DISTINCT au.user) AS total_active_users,
COUNT(DISTINCT nu.user) AS total_new_users
FROM
user_activity ua
LEFT JOIN active_users au ON ua.user = au.user
LEFT JOIN new_users nu ON ua.user = nu.user
QueryRunArchived: QueryRun has been archived