RamaharCosmos User Retention
Updated 2022-12-17
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 first_t as (select
tx_id,
block_timestamp,
tx_from,
row_number () over (partition by tx_from order by block_timestamp asc) as row_number
from cosmos.core.fact_transactions
where block_timestamp::date >= '2022-01-01'),
second_t as (select
tx_id,
block_timestamp,
tx_from,
row_number () over (partition by tx_from order by block_timestamp asc) as row_number
from cosmos.core.fact_transactions
where block_timestamp::date >= '2022-01-01'),
time_diff as (select
a.tx_from,
timediff (hour,a.block_timestamp,b.block_timestamp) as day_difference
from first_t a join second_t b on a.tx_from = b.tx_from and b.row_number = a.row_number + 1
)
select
CASE
when day_difference = '0' then 'Within a day'
when day_difference between 1 and 7 then 'Within A week'
when day_difference between 7 and 14 then 'Within 2 weeks'
when day_difference between 14 and 30 then 'Within A month'
when day_difference between 30 and 90 then 'Within 3 months'
else 'More than a quarter' end as time_zone,
count(tx_from)
from time_diff
group by 1
Run a query to Download Data