Created
August 28, 2014 10:17
-
-
Save rvanlieshout/a00ffab88b70846603d3 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 row_number FROM ( | |
SELECT row_number() OVER (ORDER BY created_at NULLS LAST) AS row_number, id | |
FROM posts | |
WHERE user_id = 123 | |
ORDER BY created_at | |
) posts | |
WHERE posts.id = 3 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not ordering by created_at since it's the same order as the id (auto increment)