HaisenbergRetention Pareto Demo
Updated 2024-07-03
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 get_volume_per_user as ( -- this is data prep
select
buyer_address
, sum(price_usd) as total_volume
from ethereum.nft.ez_nft_sales
where platform_name = 'blur'
and block_timestamp >= current_timestamp() - interval '1 year'
group by 1
order by total_volume desc
)
, get_cumulative_count as (
select
* , sum(total_volume) over(order by total_volume desc) as cumulative_count
from get_volume_per_user
)
, get_pct_of_cumulative_count as(
select
*, cumulative_count / max(cumulative_count) over() as pct_of_cumu_count
from get_cumulative_count
)
, pareto_label as(
select
*
, case when pct_of_cumu_count <= 0.8 then 'power' else 'normie' end as label
from get_pct_of_cumulative_count
)
select
*
, row_number() over(order by total_volume desc) as ranker -- for sanity check
from pareto_label
where total_volume is not null
order by total_volume desc
QueryRunArchived: QueryRun has been archived