DECLARE @closeReasons table ( Id int NOT NULL PRIMARY KEY...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu

Q&A for Ubuntu users and developers

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

INSERT INTO @closeReasons
    VALUES
    (1, '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 what youre asking'),
    (104, 'Too broad'),
    (105, 'primarily opinion-based'),
    (201, 'Off topic (channels)')
 

SELECT
    Top 1000 
      p.Title,
      p.Body,
      p.Tags,
      cr.Description as Label
    FROM
    Posts p LEFT OUTER JOIN
    (
        SELECT
            CAST(PostHistory.Comment AS int) AS CloseReasonId,
            Posts.*
            FROM PostHistory
            LEFT OUTER JOIN Posts ON Posts.Id = PostHistory.PostId
            WHERE
                (PostHistoryTypeId = 10) 
                AND Posts.CreationDate >= '2023-01-01'
    ) a on p.Id = a.Id
    LEFT OUTER JOIN @closeReasons cr ON cr.Id = a.CloseReasonId
    where p.CreationDate >= '2023-01-01'
    and p.PostTypeId = 1

Enter Parameters

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