Average accept rate percentage

0

Please login or register to vote for this query.

(click on this box to dismiss)

Calculate the average percent of each user's questions that have been accepted, excluding those with 4 or fewer answers.

Stack Overflow

Q&A for professional and enthusiast programmers

-- Average accept rate percentage
-- Calculate the average percent of each user's questions that have been accepted, excluding those with 4 or fewer answers.

SELECT 
    AVG(Round(t.Accepted * 100.0 / t.Total, 1)) AS [Percent],
    STDEVP(Round(t.Accepted * 100.0 / t.Total, 1)) AS [std dev]
  FROM
    (SELECT
         Count(a.Id) AS [Total],
         Sum(CASE WHEN q.AcceptedAnswerId IS NULL THEN 0 ELSE 1 END) AS [Accepted]
       FROM Posts AS a
         LEFT JOIN Posts AS q
           ON a.Id = q.AcceptedAnswerId
       WHERE a.postTypeId = 2
       GROUP BY a.OwnerUserId
   ) AS t 
  WHERE t.[Total] > 5

Enter Parameters

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