How many question would be deleted by roomba if it ignored tags

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT
    TagName,
    COUNT(Posts.Id) as Posts,
    COUNT(Posts.Id) * 100.0 / sum(count(*)) over() as [Percent]
FROM Tags
    INNER JOIN PostTags ON PostTags.TagId = Tags.id
    INNER JOIN Posts ON Posts.Id = PostTags.PostId
    
WHERE 
    Posts.ClosedDate is null and
    (-- 365-day rule (RemoveAbandondedQuestions)
   ((Posts.Score <= 0 or (Posts.Score <= 1 and Posts.OwnerUserId is null))
    -- has view count <= the age of the question in days times 1.5
    and Posts.ViewCount <= datediff(day, Posts.CreationDate, getdate())*1.5
    -- has too many comments
    and Posts.CommentCount >= 2
   )
  )
  -- has no answers
  and Posts.AnswerCount = 0
  -- post is not locked
  and coalesce((select top 1 PostHistoryTypeId
    from PostHistory
    where PostHistory.PostId = Posts.Id
      and PostHistory.PostHistoryTypeId in (14, 15) -- post locked, unlocked
    order by Id desc), 0) <> 14
  -- post is old
  and datediff(day, Posts.CreationDate, getdate()) > 365
  -- not deleted
  and Posts.DeletionDate is null
GROUP BY TagName
ORDER BY Posts desc

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results