Created
November 28, 2022 19:14
-
-
Save omerkaya1/ca2adfff77dfea665dcdd1d3acbfd01b 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
WITH ranked_records AS ( | |
SELECT row_number() OVER (PARTITION BY user_id, user_id ORDER BY created_at DESC) AS rn, | |
id, some_other_column, created_at | |
FROM user_status WHERE user_id IN (?) | |
) | |
SELECT | |
id, some_other_column, created_at | |
FROM ranked_records | |
WHERE rn=1 | |
ORDER BY user_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment