Distribution of Close Reasons

0

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.

Christianity

Q&A for committed Christians, experts in Christianity and those interested in learning more

-- 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'),
    (101, 'Duplicate'),
    (102, 'Off topic'),
    (103, 'Unclear'),
    (104, 'Too Broad'),
    (105, 'Opinion Based')

SELECT
    (CASE WHEN cr.Name IS NULL THEN '(Unknown)' ELSE cr.Name END) AS 'Close Reason',
    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
    ORDER BY Count DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results