Q&A about the site for scholars and enthusiasts of literature
;with ccounts_cte AS ( SELECT UserId AS uid, UserDisplayName AS udn, COUNT(Id) AS Ccount FROM Comments GROUP BY UserId, UserDisplayName ), pcounts_cte AS ( SELECT OwnerUserId AS uid, OwnerDisplayName AS udn, COUNT(Id) AS Pcount, SUM(case when PostTypeId = 1 then 1 else 0 end) AS QCount, SUM(case when PostTypeId = 2 then 1 else 0 end) AS ACount FROM Posts GROUP BY OwnerUserId, OwnerDisplayName ) SELECT TOP(##num?100##) c.uid AS [User Link], c.udn AS [DisplayName], ROUND((CAST(c.CCount AS decimal))/(CAST(p.PCount AS decimal)),2) AS [Ratio], c.CCount AS [Comments #], p.PCount AS [Posts #], p.ACount AS [Answers #], p.QCount AS [Questions #] FROM ccounts_cte c INNER JOIN pcounts_cte p ON ((c.uid=p.uid)) WHERE (p.PCount>0) AND (p.PCount>=##min?10##) ORDER BY (CAST(c.CCount AS decimal))/(CAST(p.PCount AS decimal)) ASC