Afonso_DiazGrouping users by active days
Updated 2025-01-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
main as (
select
tx_hash,
block_timestamp,
from_address as user,
tx_fee
from
mantle.core.fact_transactions
where
tx_succeeded
and block_timestamp::date between '{{ start_date }}' and '{{ end_date }}'
),
users as (
select
user,
count(distinct tx_hash) as transactions,
count(distinct block_timestamp::date) as active_days
from
main
group by 1
)
select
case
when active_days <= 7 then 'a. 1 days - 1 week'
when active_days <= 14 then 'b. 1 week - 2 weeks'
when active_days <= 30 then 'c. 2 weeks - 1 month'
when active_days <= 90 then 'd. 1 month - 3 months'
when active_days <= 180 then 'e. 3 months - 6 months'
when active_days <= 364 then 'f. 6 months - 1 year'
else 'g. > 1 year'
end as type,
count(distinct user) as users
QueryRunArchived: QueryRun has been archived