bryguyUntitled Query
Updated 2021-11-15
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 ORACLE_PRICES AS (
SELECT DATE(BLOCK_TIMESTAMP) as BLOCK_DATE,
SYMBOL,
AVG(price_USD) as AVG_DAILY_PRICE
FROM terra.oracle_prices
WHERE DATEDIFF(D, BLOCK_DATE, CURRENT_DATE) <= 30
GROUP BY BLOCK_DATE, SYMBOL
),
*/
WITH FEES_PAID AS (
SELECT
DATE(block_timestamp) as BLOCK_DATE,
case
when chain_id = 'columbus-5' then UPPER(
SUBSTRING(fee [0] :amount [0] :denom :: string, 2, 100)
)
else UPPER(SUBSTRING(fee [0] :denom :: string, 2, 100))
end as currency,
sum(
case
when chain_id = 'columbus-5' then fee [0] :amount [0] :amount
else fee [0] :amount
end
) / POW(10, 6) as fee
FROM
terra.transactions
WHERE
CURRENCY IS NOT NULL
AND DATEDIFF(D, BLOCK_DATE, CURRENT_DATE) <= 60
GROUP BY
BLOCK_DATE,
CURRENCY
)
SELECT
*
FROM
Run a query to Download Data