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)

Open Source Meta

Q&A about the site for people organizing, marketing or licensing open source development projects

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, ph.Id desc) AS Rank
    FROM PostHistory ph
    WHERE ph.Comment IS NOT NULL) AS rt
WHERE rt.Rank = 1;

Enter Parameters

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