Answered Count by Post State

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
    HasAnswer,
    State,
    COUNT(*) AS NumPosts,
    ROUND((100.0 * COUNT(*)) / SUM(COUNT(*)) OVER (), 2) AS PercentPosts
FROM (
    SELECT
        CASE
            WHEN AnswerCount = 0 THEN 'No'
            ELSE 'Yes'
        END AS HasAnswer,
        CASE
            WHEN DeletionDate IS NOT NULL THEN 'Deleted'
            WHEN ClosedDate IS NOT NULL THEN 'Closed'
            ELSE 'Open'
        END AS State
    FROM Posts
    WHERE Posts.PostTypeId = 1 -- Questions
) AS x
GROUP BY HasAnswer, State

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results