Created
October 2, 2013 02:51
-
-
Save benhoskings/6788475 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 DISTINCT comments.id, comments.content_id, comments.created_at -- whatever fields you like | |
FROM comments | |
INNER JOIN ( | |
SELECT comments.id, first_value(comments.id) | |
OVER (PARTITION BY content_id ORDER BY created_at DESC) comment_id | |
FROM comments | |
) chosen | |
ON chosen.comment_id = comments.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment