-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Jan Gorecki <[email protected]>
- Loading branch information
1 parent
5f20f37
commit 941942b
Showing
2 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ion/snapshots/documentation__book__reference__stdlib__transforms__window__example__2.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
source: web/book/tests/documentation/book.rs | ||
expression: "from [\n {time_id=1, value=15},\n {time_id=2, value=11},\n {time_id=3, value=16},\n {time_id=4, value=9},\n {time_id=7, value=20},\n {time_id=8, value=22},\n]\nwindow rows:-2..0 (\n sort time_id\n derive {sma3rows = average value}\n)\nwindow range:-2..0 (\n sort time_id\n derive {sma3range = average value}\n)\n" | ||
--- | ||
WITH table_0 AS ( | ||
SELECT | ||
1 AS time_id, | ||
15 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
2 AS time_id, | ||
11 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
3 AS time_id, | ||
16 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
4 AS time_id, | ||
9 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
7 AS time_id, | ||
20 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
8 AS time_id, | ||
22 AS value | ||
) | ||
SELECT | ||
time_id, | ||
value, | ||
AVG(value) OVER ( | ||
ORDER BY | ||
time_id ROWS BETWEEN 2 PRECEDING AND CURRENT ROW | ||
) AS sma3rows, | ||
AVG(value) OVER ( | ||
ORDER BY | ||
time_id RANGE BETWEEN 2 PRECEDING AND CURRENT ROW | ||
) AS sma3range | ||
FROM | ||
table_0 | ||
ORDER BY | ||
time_id | ||
|