Afonso_Diaz2023-04-16 09:20 PM
Updated 2023-04-16
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
t as (
select
recorded_hour::date as date,
currency,
symbol,
avg(price) as price_usd
from osmosis.core.ez_prices
group by 1, 2, 3
),
t2 as (
select
action,
block_timestamp,
tx_id,
((amount * price_usd) / pow(10, decimal)) as amount_usd,
delegator_address as user
from osmosis.core.fact_staking a
join t on a.currency = t.currency and a.block_timestamp::date = t.date
where block_timestamp >= '2023-01-01' and block_timestamp < '2023-04-01'
and action in ('delegate', 'undelegate')
)
select
action,
case
when amount_usd < 10 then 'Less than 10$'
when amount_usd < 100 then '10$ - 100$'
when amount_usd < 1000 then '100$ - 1000$'
when amount_usd < 10000 then '1000$ - 10,000$'
else 'More than 10,000$' end as type,
count(distinct tx_id) as transactions
from t2
group by 1, 2
order by 1, 2
Run a query to Download Data