Created
December 27, 2021 13:37
-
-
Save zseta/f14946f95262f2494942f68a5deca222 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
/* | |
If last close exists: open = last_close, else open = first(price) | |
*/ | |
SELECT | |
time_bucket('1 day', time) AS bucket, | |
symbol, | |
CASE | |
WHEN LAST(price_close, time) IS NOT NULL THEN LAST(price_close, time) | |
ELSE FIRST(price_open, time) | |
END AS price_open | |
FROM stocks_intraday | |
GROUP BY bucket, symbol | |
LIMIT 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment