Distribution of Close Reasons

2

Please login or register to vote for this query.

(click on this box to dismiss)

Summary of the number of questions closed by the close reason type.

Stack Overflow

Q&A for programmers

-- Distribution of Close Reasons
-- Summary of the number of questions closed by the close reason type.

DECLARE @closeReasons table
(
    Id int NOT NULL PRIMARY KEY,
    Name nvarchar(200) NOT NULL
)

INSERT INTO @closeReasons
    VALUES
    (1, 'Exact duplicate'),
    (2, 'Off topic'),
    (3, 'Subjective and argumentative'),
    (4, 'Not a real question'),
    (7, 'Too localized'),
    (20, 'Noise or pointless')

SELECT
    (CASE WHEN cr.Name IS NULL THEN '(Unknown)' ELSE cr.Name END) AS 'Close Reason',
    CAST(PostHistory.Comment AS int) AS CloseReasonId,
    SUM(1) AS Count
    FROM PostHistory
    LEFT OUTER JOIN @closeReasons cr ON cr.Id = CAST(PostHistory.Comment AS int)
    WHERE PostHistoryTypeId = 10
    GROUP BY cr.Name, CAST(PostHistory.Comment AS int)
    ORDER BY Count DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached