SITE HEALTH VALUE from Area51 statistics -> Percentage Answered (http://area51.stackexchange.com/proposals/42810/stack-overflow-in-spanish) --- Percent Answered in SE sites (http://stackexchange.com/sites#percentanswered) ---- Formula: %Answered = (Accepted + Answer_Has_Positive_Score + Closed) / Questions_Including_Closed ---- Source: http://meta.stackexchange.com/a/86976/304899
Q&A for ebook publishers and readers
WITH Answers AS ( -- unique answers with best score per question SELECT ParentId AS Id, MAX(Score) AS Score FROM Posts WHERE PostTypeId = 2 GROUP BY ParentId ) , Counts AS ( SELECT -- Count for questions joined with answers COUNT(*) AS Asked, SUM(IIF(Q.AcceptedAnswerId IS NOT NULL AND Q.ClosedDate IS NULL, 1, 0)) AS AcceptedNotClosed, SUM(IIF(Q.AcceptedAnswerId IS NULL AND A.Score > 0 AND Q.ClosedDate IS NULL, 1, 0)) AS PositiveScoreNotAcceptedNotClosed, SUM(IIF(Q.ClosedDate IS NULL, 0, 1)) AS Closed FROM Posts Q LEFT OUTER JOIN Answers A ON Q.Id = A.Id WHERE Q.PostTypeId = 1 ) SELECT Asked, AcceptedNotClosed, PositiveScoreNotAcceptedNotClosed, Closed, (AcceptedNotClosed + PositiveScoreNotAcceptedNotClosed + Closed) AS Answered, (Asked - (AcceptedNotClosed + PositiveScoreNotAcceptedNotClosed + Closed)) AS Unanswered, Cast(Cast( (AcceptedNotClosed + PositiveScoreNotAcceptedNotClosed + Closed) / CAST(Asked AS FLOAT) *100 as decimal(18,2) ) as varchar(5)) + ' %' AS "%Answered" FROM Counts