SELECT rt.PostId, rt.Comment AS LastComment FROM( SELECT ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Webmasters

Q&A for pro webmasters

SELECT rt.PostId, rt.Comment AS LastComment
FROM(
    SELECT ph.PostId
          , ph.Comment
          , ROW_NUMBER () OVER (partition by (ph.PostId) 
          ORDER BY (ph.CreationDate) DESC) AS Rank
    FROM PostHistory ph
    WHERE ph.Comment IS NOT NULL) AS rt
WHERE rt.Rank = 1;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results