thejoyceoptimistic-tomato
Updated 2024-09-30
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 new_users AS (
SELECT
MIN(block_timestamp::date) AS day,
from_address
FROM
blast.core.fact_transactions
WHERE
status = 'SUCCESS'
GROUP BY
from_address
),
filtered_new_users AS (
SELECT
day,
COUNT(DISTINCT from_address) AS "New Users"
FROM
new_users
WHERE
day >= DATEADD(day, -30, CURRENT_DATE) -- Only include data from the last 30 days
GROUP BY
day
),
total_new_users AS (
SELECT
day,
"New Users",
SUM("New Users") OVER (ORDER BY day ASC) AS "Cumulative New Users"
FROM
filtered_new_users
)
-- Final query to calculate total new users and average daily new users
SELECT
SUM("New Users") AS total_new_users,
AVG("New Users") AS avg_daily_new_users
FROM
QueryRunArchived: QueryRun has been archived