Last active
May 14, 2019 04:00
-
-
Save lettergram/d7031fd45e458b5066aadc9ba3669ba1 to your computer and use it in GitHub Desktop.
Create a subquery in PostgreSQL
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
/** | |
* comments | |
* author | |
* comment_text | |
* created_at | |
**/ | |
SELECT author, created_at FROM | |
(SELECT * FROM comments WHERE (created_at >= NOW() - interval '6 month') | |
ORDER BY created_at DESC LIMIT 100) subquery | |
ORDER BY author ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment