User Answer Accepted Rate

1

Please login or register to vote for this query.

(click on this box to dismiss)

Shows the percentage of a user's answers that are accepted, excluding self-acceptances. Based on http://data.stackexchange.com/stackoverflow/s/100/users-with-highest-accept-rate-of-their-answers

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @UserId int = ##UserId##

SELECT
  u.Id AS [User Link],
  count(*) AS NumAnswers,
  sum(case when q.AcceptedAnswerId = a.Id then 1 else 0 end) AS NumAccepted,
  (sum(case when q.AcceptedAnswerId = a.Id then 1 else 0 end)*100.0/count(*)) AS AcceptedPercent
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
  and u.id = @UserId
GROUP BY u.Id
ORDER BY AcceptedPercent DESC, NumAnswers DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results