Created
June 29, 2023 09:51
-
-
Save Ugbot/fd3a20fe2edb8a4fda72f92e007ae887 to your computer and use it in GitHub Desktop.
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
SELECT | |
window_start, | |
CEIL(row_num / 50.0) AS bundle, | |
COUNT(*), | |
AVG(value), | |
MAX(value), | |
MIN(value) | |
FROM ( | |
SELECT | |
*, | |
ROW_NUMBER() OVER (PARTITION BY window_start ORDER BY timestamp) as row_num | |
FROM ( | |
SELECT | |
*, | |
TUMBLE_START(timestamp, INTERVAL '5' SECOND) as window_start | |
FROM my_table | |
) | |
) t | |
GROUP BY window_start, CEIL(row_num / 50.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment