Rate of accepted answers

1

Please login or register to vote for this query.

(click on this box to dismiss)

Count answers and accepted answers and show the resulting accept rate for a given user. Deleted and community wiki answers excluded.

Stack Overflow

Q&A for programmers

SELECT ct AS [Total answers]
     , accept AS [Accepted answers]
     , accept * 100 / ct AS [Accept rate]
FROM (
   SELECT count(*) AS ct
         ,sum(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END) AS accept
   FROM   Posts q 
   JOIN   Posts a on a.ParentId = q.Id
   WHERE  q.PostTypeId = 1 
   AND    a.ClosedDate IS NULL
   AND    q.ClosedDate IS NULL
   -- AND    a.CommunityOwnedDate IS NULL
   AND    a.PostTypeId = 2 
   AND    a.OwnerUserId = ##UserId##
   ) AS sub;

Enter Parameters

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