I have multiple users submitting comments on multiple blog posts. Users can comment multiple times on each blog post. I need a SQL Query (sql server 2008) to get the last comment for each User given a BlogPostId.
Lets say 3 users submit a total of 10 comments on a specific blog post. For Blog Post #1, User A has submitted 5 comments, user B has submitted 2 comments, and user C has submitted 3 comments.
For a specific BlogPostId (eg. #1) how would I get the latest comment for each user limiting it to their most recent comment only (eg. one comment per user)?
The end result should produce three rows (eg.)
(User A) CommentId, BlogPostId, UserId, CommentData
(User B) CommentId, BlogPostId, UserId, CommentData
(User C) CommentId, BlogPostId, UserId, CommentData