Questions escaping from auto-deletion due to comments

1

Please login or register to vote for this query.

(click on this box to dismiss)

Questions escaping from RemoveAbandonedQuestions script due to comments. More context on: https://meta.stackexchange.com/questions/322197/modify-the-has-1-or-0-comments-requirement-for-removeabandonedquestions-scri

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT p.Id AS [Post Link],
       p.CreationDate,
       p.Score,
       p.CommentCount
FROM Posts p
WHERE p.PostTypeId = 1 -- questions.
      AND p.CreationDate < GETDATE() - 365 -- older than 365 days.
      AND (
          (p.OwnerUserId IS NULL AND p.Score < 2) -- questions with deleted owners
          OR
          (p.OwnerUserId IS NOT NULL AND p.Score < 1)
          )
      AND p.AnswerCount = 0
      AND NOT EXISTS 
      (
       SELECT *
       FROM PostHistory ph
       WHERE ph.PostId = p.Id
       AND ph.PostHistoryTypeId = 14 -- not locked
      )
      AND p.ViewCount <= DATEDIFF(DAY, p.CreationDate, GETDATE()) * 1.5
      AND p.CommentCount > 1
      AND p.ClosedDate IS NULL
ORDER BY p.CreationDate DESC, p.Score DESC, --verify deleted owner rule (where score = 1).
         p.CommentCount ASC;

Enter Parameters

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