SELECT ROUND( AVG( AcceptedPercentage.Accepted ), 2 ) AS ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT
    ROUND( AVG( AcceptedPercentage.Accepted ), 2 ) AS [Accepted Answer Percentage]
FROM
    ( 
    SELECT TOP 10000
        ROUND(
            SUM( CASE Questions.AcceptedAnswerId 
               WHEN Answers.Id THEN 1 
               ELSE 0 END
            ) 
            * 100.0 / COUNT( Answers.Id )
        , 1)                            AS [Accepted]
        
    FROM    
        Posts                           AS Answers
        
        INNER JOIN    
        Posts                           AS Questions
        ON Answers.ParentId             = Questions.Id
    WHERE
            Questions.PostTypeId        = 1
        AND Answers.PostTypeId          = 2
        AND Questions.AcceptedAnswerId  IS NOT NULL
        
    GROUP BY
        Answers.OwnerUserId
    ) AS AcceptedPercentage

Enter Parameters

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