WITH max_comment_dates_no_filter AS ( SELECT postid, MAX(...

0

Please login or register to vote for this query.

(click on this box to dismiss)

English Language Learners

Q&A for speakers of other languages learning English

WITH max_comment_dates_no_filter AS (
    SELECT postid, MAX(creationdate) AS max_creationdate
    FROM comments
    WHERE text IS NOT NULL
    GROUP BY postid
),
latest_comments_no_filter AS (
    SELECT c.postid, id, c.text AS latest_comment
    FROM comments c
    JOIN max_comment_dates_no_filter mcd 
      ON c.postid = mcd.postid 
      AND c.creationdate = mcd.max_creationdate
    WHERE c.text IS NOT NULL
)

select * from latest_comments_no_filter
where postid in (52716, 26276819, 3434174, 5571525, 78899597)

-- total comments 30396666
-- total comments 30396780 old query

-- 52716, 26276819, 3434174, 5571525, 78899597

Enter Parameters

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