Threads with the largest number of comments

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT TOP 100
  IsNull(p.ParentId, p.Id) AS [Post Link],
  Sum(p.CommentCount) AS [#Comments],
  Max(CASE p.PostTypeId WHEN 1 THEN p.CommentCount ELSE 0 END) AS [#Q com],
  Max(p.AnswerCount) AS [#Ans],
  Max(p.ViewCount) AS [Views],
  Max(CASE p.PostTypeId WHEN 1 THEN p.Score ELSE -32767 END) AS [Q score],
  Sum(p.Score) AS [Total score],
  Min(p.CreationDate) AS [Q date]
FROM Posts p
GROUP BY IsNull(p.ParentId, p.Id)
ORDER BY [#Comments] DESC

Enter Parameters

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