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