SalehUntitled Query
Updated 2022-10-24
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 prices as (
select recorded_at::date as days,
symbol,
address,
avg (price) as USDPrice
from osmosis.core.dim_prices a join osmosis.core.dim_labels b on project_name = symbol
group by 1,2,3),
balances as (
select
-- date_trunc(week,date) as day,
symbol,
currency,
case when symbol='INJ' then avg (balance/pow(10,18))
else sum (balance/pow(10,decimal)) end as avg_balance ,
case when symbol='INJ' then avg (balance*usdprice/pow(10,18))
else sum (balance*usdprice/pow(10,decimal)) end as avg_usd_balance
from osmosis.core.fact_daily_balances a join prices b on a.currency = b.address and a.date = b.days
group by 1,2
having avg_usd_balance > 0)
select *
from balances
-- where rank <= 10
-- order by day
Run a query to Download Data