Q&A for Drupal developers and administrators
select s.postid, s.text from (SELECT c.postid ,c.text ,ROW_NUMBER () OVER (PARTITION BY c.postid ORDER BY c.creationdate DESC) AS rn FROM comments c) as s where s.rn = 1;