SELECT p.id ,s.text ,s.rn FROM posts p LEFT JOIN( SELECT ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers

Q&A for Drupal developers and administrators

SELECT
p.id
,s.text
,s.rn
FROM posts p
LEFT JOIN(
      SELECT 
          c.postid
         ,c.text
         ,ROW_NUMBER () OVER (ORDER BY (c.creationdate) DESC) AS rn
      FROM comments c) s
ON p.id = s.postid
where s.rn = 1;

Enter Parameters

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