nitinpatel17hsUntitled Query
Updated 2023-02-03Copy 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
27
28
29
30
31
32
33
34
35
›
⌄
with a as
(
select date,
address,
balance/power(10,6) as balance,
rank() over (partition by date order by balance/power(10,6) desc) as rnk
from osmosis.core.fact_daily_balances
where currency = 'uosmo' and date = date_trunc('month' , date) + interval '1 month' - interval '1 day'
)
select a.date as mnth,
count(distinct case when a.balance > 0 then a.address else null end) as token_holders,
sum(case when a.rnk <= 100 then a.balance else 0 end)*100.0/(1000000000) as top_100_whales_holding,
sum(case when a.rnk <= 10 then a.balance else 0 end)*100.0/(1000000000) as top_10_whales_holding
-- sum(case when a.rnk <= 100 then a.balance else 0 end)*100.0/sum(a.balance) as top_100_whales_holding,
-- sum(case when a.rnk <= 10 then a.balance else 0 end)*100.0/sum(a.balance) as top_10_whales_holding
from a
group by 1
order by 1
-- select date_trunc('month' , cast('2021-09-09' as date)) + interval '1 month' - interval '1 day'
Run a query to Download Data