Q&A for SharePoint enthusiasts
WITH TagQACounts AS ( SELECT T.TagName, COUNT(P.Id) AS QuestionCount, SUM(CASE WHEN AnswerCount > 0 THEN 1 ELSE 0 END) AS WithAnyAnswer, SUM(CASE WHEN AcceptedAnswerId IS NULL THEN 0 ELSE 1 END) AS WithAcceptedAnswer, AVG(CAST(P.AnswerCount as decimal(10,2))) AS AvgAnsCount FROM Posts P INNER JOIN PostTags PT ON PT.PostId = P.Id INNER JOIN Tags T ON T.Id = PT.TagId GROUP BY T.TagName ) SELECT TagName, QuestionCount, WithAnyAnswer, WithAcceptedAnswer, AvgAnsCount, (WithAnyAnswer * 100.00)/QuestionCount AS PercentAnswered, (WithAcceptedAnswer * 100.00)/QuestionCount AS PercentAccepted FROM TagQACounts WHERE TagName IN ('react-native')