Does not count self-answers. Shows users with at least @MinAnswers answers.
Q&A for SharePoint enthusiasts
-- 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], count(*) AS NumAnswers, sum(case when q.AcceptedAnswerId = a.Id then 1 else 0 end) AS NumAccepted, sum( ca.CompetingAnswers ) AS CompetingAnswers, (sum(case when q.AcceptedAnswerId = a.Id then 1/(1.0 * ca.CompetingAnswers ) else 0 end)*100.0/COUNT(*)) AS WeightedAcceptedPercent FROM Posts a INNER JOIN Users u ON u.Id = a.OwnerUserId INNER JOIN Posts q ON a.ParentId = q.Id LEFT JOIN ( SELECT qc.AcceptedAnswerId, COUNT( ac.Id ) AS CompetingAnswers FROM Posts qc INNER JOIN Posts ac ON ac.ParentId = qc.Id AND ac.PostTypeId = 2 WHERE qc.PostTypeId = 1 AND qc.AcceptedAnswerId IS NOT NULL AND ( qc.OwnerUserId <> ac.OwnerUserId OR qc.OwnerUserId IS NULL ) GROUP BY qc.AcceptedAnswerId ) ca ON ca.AcceptedAnswerId = a.Id WHERE (q.OwnerUserId <> u.Id OR q.OwnerUserId IS NULL) --no self answers GROUP BY u.Id HAVING count(*) >= @MinAnswers ORDER BY WeightedAcceptedPercent DESC, NumAnswers DESC