feyikemiorganic-coffee
Updated 2025-01-28
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
›
⌄
-- Credit to 0xDataWolf https://flipsidecrypto.xyz/0xDataWolf/q/jEC6M61jinzx/time-based-cohort-wide.
WITH Users_data AS(
SELECT
Block_timestamp,
from_address
FROM kaia.core.fact_transactions
),
Users_activity AS (
SELECT
from_address AS Users,
Date_trunc('month', Block_timestamp) AS Activity_month,
Min(Date_trunc('month', Block_timestamp)) OVER (PARTITION BY from_address) AS First_activity_month,
DATEDIFF(
'month',
MIN(Date_trunc('month', Block_timestamp)) OVER (PARTITION BY from_address),
Date_trunc('month', Block_timestamp)
) AS Month_difference
FROM Users_data
WHERE Block_timestamp >= '2023-10-01'
),
new_users AS (
SELECT
first_activity_month,
COUNT(DISTINCT users) AS new_user_count
FROM Users_activity
GROUP BY 1
),
returning_users AS (
SELECT
first_activity_month,
month_difference,
COUNT(DISTINCT users) AS returning_user_count
QueryRunArchived: QueryRun has been archived