List all locked answers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Lists all currently locked posts, most recent first.

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT p.Score,
       p.Id                AS [Post Link],
       p.CreationDate      AS [Creation Date],
       MAX(h.CreationDate) AS [Locked Date],
       p.OwnerUserId       AS [User Link]
FROM   Posts p
       INNER JOIN PostHistory h
         ON h.PostId = p.Id
WHERE  h.PostHistoryTypeId IN (14) -- locked, unlocked
        AND p.PostTypeId = 2 -- answer
        and p.Score < 10
GROUP  BY p.Id, p.Score, p.CreationDate, p.OwnerUserId -- derp?
HAVING SUM(CASE WHEN h.PostHistoryTypeId = 14 THEN 1 ELSE -1 END) > 0 -- locked more often than unlocked
ORDER  BY [Score] DESC

Enter Parameters

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