Created
January 21, 2024 13:13
-
-
Save xescuder/b750af70a448a793024ca17fff07b982 to your computer and use it in GitHub Desktop.
Return changes between today and 1 year ago
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 s.symbol, s.sector, first(close, date) AS first_close, last(close, date) AS last_close, | |
MIN(date) AS first_date, | |
MAX(date) AS last_date, | |
100 * (last(close, date) - first(close, date)) / first(close, date) AS return_change | |
FROM | |
daily_bars db, stocks s | |
WHERE | |
db.date >= now() - interval '1 year' AND db.symbol = s.symbol | |
GROUP BY | |
s.symbol | |
ORDER BY | |
return_change DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment