jackguynear stake 4
Updated 2023-08-04
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 latest_changes AS (
SELECT
ADDRESS AS stake_pool,
MAX(BLOCK_TIMESTAMP) AS latest_change
FROM near.core.fact_staking_pool_balances
GROUP BY stake_pool
)
, current_balances AS (
SELECT
l.stake_pool,
b.BALANCE AS current_balance
FROM latest_changes l
JOIN near.core.fact_staking_pool_balances b
ON l.stake_pool = b.ADDRESS AND l.latest_change = b.BLOCK_TIMESTAMP
)
, balance_buckets AS (
SELECT
stake_pool,
current_balance,
CASE
WHEN current_balance <= 50000 THEN 'a 0 - 50K'
WHEN current_balance > 50000 AND current_balance <= 500000 THEN 'b 50K - 500K'
WHEN current_balance > 500000 AND current_balance <= 1000000 THEN 'c 500K - 1M'
WHEN current_balance > 1000000 AND current_balance <= 5000000 THEN 'd 1M - 5M'
WHEN current_balance > 5000000 AND current_balance <= 10000000 THEN 'e 5M - 10M'
ELSE 'f 10M+'
END AS balance_bucket
FROM current_balances
)
SELECT
balance_bucket,
COUNT(stake_pool) AS num_pools,
sum(current_balance) staked_near
Run a query to Download Data