Multipartite2022-05-25 Terra pool RUNE depths
Updated 2022-05-25Copy 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
›
⌄
WITH
depths AS
(
SELECT DISTINCT block_timestamp, block_id, pool_name,
CAST(POWER(10,-8) * rune_e8 AS DECIMAL(17,8)) AS rune_depth
FROM thorchain.block_pool_depths
WHERE pool_name IN ('TERRA.UST', 'TERRA.LUNA')
),
rowcounting AS
(
SELECT
COUNT(depths.*) AS rowcount,
10000 AS target_rows
FROM depths
)
SELECT depths.*
FROM depths, rowcounting
QUALIFY (
(MOD((ROW_NUMBER() OVER(ORDER BY block_id ASC)), CEIL(rowcount/target_rows)) = 0)
--Row-sampling.
OR (ROW_NUMBER() OVER(ORDER BY block_id ASC) = 1)
--Include the first data point.
OR (ROW_NUMBER() OVER(ORDER BY block_id DESC) = 1)
--Include the last data point.
)
ORDER BY block_id DESC
Run a query to Download Data