Users with highest accept rate of their answers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Does not count self-answers. Shows users with at least @MinAnswers answers.

Craft CMS Meta

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

-- Users with highest accept rate of their answers
-- Does not count self-answers. 
-- Shows users with at least @MinAnswers answers.

DECLARE @MinAnswers int = ##MinAnswers##


SELECT top 100
  u.Id AS [User Link], u.Reputation,
  count(*) AS NumAnswers,
  sum(q.score),
  sum(case when q.AcceptedAnswerId = a.Id then 1 else 0 end) AS NumAccepted
  
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.Id, u.Reputation
HAVING count(*) >= @MinAnswers
ORDER BY u.Reputation DESC

Enter Parameters

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