Users with highest reputation-to-number-of-answers ratio

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A about the site for administrators, end users, developers and designers for Craft CMS

-- Users with highest reputation-to-number-of-answers ratio
-- Does not count self-answers. 
-- Shows users with at least @MinAnswers answers.

DECLARE @MinAnswers int = ##MinAnswers##

SELECT TOP 200
  u.Id AS [User Link],
  count(*) AS NumAnswers,
  u.Reputation AS Reputation,
  CAST(Reputation*1.0/count(*) AS DECIMAL(5,2)) AS ratio
FROM Posts a
INNER JOIN Users u ON u.Id = a.OwnerUserId
INNER JOIN Posts q ON a.ParentId = q.Id
WHERE 
  (q.OwnerUserId <> u.Id OR q.OwnerUserId IS NULL)   --no self answers
GROUP BY u.Reputation, u.Id, u.DisplayName
HAVING count(*) >= @MinAnswers
ORDER BY ratio DESC, NumAnswers DESC

Enter Parameters

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