HosseinNEAR Distribution
Updated 2022-09-08
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
list1 as (
select tx_receiver as wallet_address, sum(tx:actions[0]:transfer:deposit / pow(10, 24)) as amount_sum
from near.core.fact_transactions
where tx_status = 'Success'
and tx:actions[0]:transfer:deposit > 0
group by tx_receiver
),
list2 as (
select tx_signer as wallet_address, sum(tx:actions[0]:transfer:deposit / pow(10, 24)) as amount_sum
from near.core.fact_transactions
where tx_status = 'Success'
and tx:actions[0]:transfer:deposit > 0
group by tx_signer
),
near_balance as (
select list1.wallet_address, (list1.amount_sum - list2.amount_sum) as total_balance
from list1
join list2 on list1.wallet_address = list2.wallet_address
)
select count(case when total_balance between 1 and 100 then wallet_address end) as dist, '1 - 100' as dist_name
from near_balance
union all
select count(case when total_balance between 100 and 1000 then wallet_address end), '100 - 1000'
FROM near_balance
union all
select count(case when total_balance between 1000 and 10000 then wallet_address end), '1000 - 10000'
FROM near_balance
union all
select count(case when total_balance between 10000 and 100000 then wallet_address end), '10000 - 100000'
FROM near_balance
union all
select count(case when total_balance between 100000 and 1000000 then wallet_address end), '100000 - 1000000'
from near_balance
Run a query to Download Data