Created
February 22, 2014 02:31
-
-
Save drobison/9147755 to your computer and use it in GitHub Desktop.
Find latest entry in a group SQL
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 p.id | |
| FROM Posts as p | |
| JOIN ( | |
| SELECT id | |
| , MAX(date_modified) as ModifiedDate | |
| FROM Posts | |
| GROUP BY user_id | |
| ) lastPost ON p.id = lastPost.id | |
| AND p.date_modified = lastPost.ModifiedDate | |
| order by p.user_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment