Q&A about the site for committed Christians, experts in Christianity and those interested in learning more
COUNT(*) AS NumPosts,
ROUND((100.0 * COUNT(*)) / SUM(COUNT(*)) OVER (), 2) AS PercentPosts
WHEN COUNT(Answers.Id) >= 1 THEN 'Yes'
END AS HasAnswer,
WHEN Questions.DeletionDate IS NOT NULL THEN 'Deleted'
WHEN Questions.ClosedDate IS NOT NULL THEN 'Closed'
END AS State
FROM PostsWithDeleted AS Questions
LEFT JOIN PostsWithDeleted AS Answers ON (
Answers.Id = Questions.ParentId
AND Answers.PostTypeId = 2
WHERE Questions.PostTypeId = 1
GROUP BY Questions.Id, Questions.DeletionDate, Questions.ClosedDate
) AS QData
GROUP BY HasAnswer, State
ORDER BY HasAnswer, State