Q&A for Drupal developers and administrators
SELECT c.postid ,c.text ,ROW_NUMBER () OVER (partition by c.postid ORDER BY c.creationdate DESC) rn FROM comments c