Skip to content

Instantly share code, notes, and snippets.

@thistleknot
Last active September 18, 2022 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thistleknot/5678d338f57d9bbd2a6c3a6e91384857 to your computer and use it in GitHub Desktop.
Save thistleknot/5678d338f57d9bbd2a6c3a6e91384857 to your computer and use it in GitHub Desktop.
Find max quarterly return
SELECT p."Date"
,p."Symbol"
,p."ratio_roll_qtr_ret"
FROM PUBLIC."prices_vw" AS p
JOIN (
SELECT "Symbol"
,max("Date")
FROM PUBLIC."prices_vw"
GROUP BY "Symbol"
) AS sq ON p."Date" = sq."max"
AND p."Symbol" = sq."Symbol"
WHERE p."ratio_roll_qtr_ret" IS NOT NULL
ORDER BY "ratio_roll_qtr_ret" DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment