How many questions have I helped to close?

16

Please login or register to vote for this query.

(click on this box to dismiss)

Shows the breakdown of the close reasons you've used in successfully closed questions.

Q&A for programmers

-- How many questions have I helped to close?
-- Shows the breakdown of the close reasons you've used in successfully closed questions.

DECLARE @userId int = ##UserId##
DECLARE @searchUserId1 nvarchar(25) = '%"Id":' + CAST(@userId AS nvarchar(MAX)) + '}'
DECLARE @searchUserId2 nvarchar(25) = '%"Id":' + CAST(@userId AS nvarchar(MAX)) + ',%'

DECLARE @closeReasons table
(
    Id int NOT NULL PRIMARY KEY,
    Description 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 GROUPING(Description) = 1 THEN
            '(Total)'
        ELSE
            (CASE WHEN Description IS NULL THEN '(Unknown)' ELSE Description END)
        END
    ) AS 'Close Reason',
    SUM(Count) AS Count
    FROM
    (
        SELECT
            CAST(PostHistory.Comment AS int) AS CloseReasonId,
            1 AS Count
            FROM PostHistory
            WHERE
                (PostHistoryTypeId = 10) AND
                ((Text LIKE @searchUserId1) OR (Text LIKE @searchUserId2))
    ) a
    LEFT OUTER JOIN @closeReasons cr ON cr.Id = a.CloseReasonId
    GROUP BY Description WITH ROLLUP
    ORDER BY
        GROUPING(Description),
        SUM(Count) DESC

Enter Parameters

Options:
Switch sites:
Hold tight while we fetch your results
:records rows returned in :time ms:cached
{"cc_re__cc_re__cc_by_sa_3_0": ["    <span style=\"color:#00adee;font-size:140%\">\u25a0</span>&nbsp;<a href=\"http://dba.stackexchange.com\">dba</a>&nbsp;\r\n                    <span style=\"color:#2edaf0;font-size:140%\">\u25a0</span>&nbsp;<a href=\"http://drupal.stackexchange.com\">drupal</a>&nbsp;\r\n                    <span style=\"color:#213951;font-size:140%\">\u25a0</span>&nbsp;<a href=\"http://sharepoint.stackexchange.com\">sharepoint</a>&nbsp;\r\n                </div>\r\n            </div>\r\n            <div id=\"footer-flair\">\r\n                <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" class=\"cc-wiki-link\"></a>\r\n                <div id=\"revision\">rev 2013.9.10.11</div>\r\n            </div>\r\n            <div id=\"copyright\">\r\n                site design / logo &copy; 2013 stack exchange inc; \r\n                    user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\"\r\n                        rel=\"license\">cc-wiki</a> with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\"\r\n                            rel=\"license\">attribution required</a>\r\n      "], "copyright__copyright__copyright": ["eReasonId,\n            1 AS Count\n            FROM PostHistory\n            WHERE\n                (PostHistoryTypeId = 10) AND\n                ((Text LIKE @searchUserId1) OR (Text LIKE @searchUserId2))\n    ) a\n    LEFT OUTER JOIN @closeReasons cr ON cr.Id = a.CloseReasonId\n    GROUP BY Description WITH ROLLUP\n    ORDER BY\n        GROUPING(Description),\n        SUM(Count) DESC\n\nEnter Parameters\n\nOptions:\nSwitch sites:\nHold tight while we fetch your results\n:records rows returned in :time ms:cached"]}