bachikrt vs ust2
Updated 2021-09-16
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
›
⌄
⌄
/*
select date_trunc(day, date) AS date, balance_type, currency, balance, balance_usd from terra.daily_balances where currency in ('UST', 'KRT')
and date > DATEADD(day, -12, getdate()) and balance_usd <> 0 order by balance_usd,date desc limit 1000 --limit 10000; */
with krt_prices as (
SELECT date_trunc(week, date) AS date, sum(balance_usd) as krt_amount from terra.daily_balances where currency = 'KRT'
and date > dateadd(month, -12, getdate())
group by date
),
ust_prices as (
SELECT date_trunc(week, date) AS date, sum(balance_usd) as ust_amount from terra.daily_balances where currency = 'UST'
and date > dateadd(month, -12, getdate())
group by date
)
SELECT * from krt_prices k left join ust_prices u
on k.date = u.date order by k.date desc limit 10000;
Run a query to Download Data