Sbhn_NPshare of near holders
Updated 2023-01-19Copy Reference Fork
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
›
⌄
with tab1 as ( select tx_receiver, sum(deposit / power(10, 24)) as in_volume
from near.core.fact_transfers
where block_timestamp >= '2023-01-01'
group by 1
),
tab2 as ( select TX_SIGNER, sum(deposit / power(10, 24)) as out_volume
from near.core.fact_transfers
where block_timestamp >= '2023-01-01'
group by 1
),
near_balance as ( select *, in_volume - out_volume as user_balance
from tab1 left outer join tab2 on tx_signer = tx_receiver
having user_balance > 0
)
select case when user_balance <= 10 then 'Shrimp'
when user_balance <= 100 then 'Crab'
when user_balance <= 1000 then 'Octubus'
when user_balance <= 10000 then 'Fish'
when user_balance <= 100000 then 'Dolphin'
when user_balance <= 1000000 then 'Shark'
when user_balance > 1000000 then 'Whale' end as category ,
count(*) as users,
sum(user_balance) as near_balance
from near_balance
group by 1
Run a query to Download Data