5

I was doing some querying on the Stack Overflow database and I noticed that the creation date of a post is sometimes later than the first or subsequent comments. The query below is the most extreme example. Is there a reason for this?

SELECT *
FROM Posts T1
LEFT JOIN Comments T2 ON T1.Id = T2.PostId
WHERE t1.id = 4318161

The following query will give a full list

SELECT 
T1.Id AS PostID,
T1.Title,
T2.Text,
DATEDIFF(minute, T1.CreationDate, T2.CreationDate) ReactionMinutes
FROM Posts T1
LEFT JOIN Comments T2 ON T1.Id = T2.PostId
WHERE T2.CreationDate = (SELECT MIN(T3.CreationDate)
                            FROM Comments T3
                            WHERE T3.PostId = T1.Id)
AND DATEDIFF(minute, T1.CreationDate, T2.CreationDate) < 0
ORDER BY DATEDIFF(minute, T1.CreationDate, T2.CreationDate)
4
  • 3
    Moderators can merge one question into another. This moves all answers and comments from the first question to the merge target. I suspect this is how you’re seeing comments with creation dates preceding the question creation date. The comments were in fact created before the question. Oct 31, 2019 at 19:54
  • Ah, that sounds like an explanation. :-) Thanks! Oh.. and thanks for the formatting. I will do better next time. :-) Oct 31, 2019 at 19:55
  • You should be able to confirm a merge by checking the question’s history. I’m on mobile right now, so I can’t easily run your query. Also, yeah, code formatting works the same on Meta as it does on the main site. Three backticks for block code formatting (or, equivalently, indent each line with 4 spaces). Oct 31, 2019 at 19:58
  • The question you queried was indeed merged. See the post revisions for the details.
    – Martijn Pieters Mod
    Nov 1, 2019 at 8:10

0

You must log in to answer this question.

Browse other questions tagged .