List all locked posts

0

Please login or register to vote for this query.

(click on this box to dismiss)

Lists all currently locked posts, most recent first.

Physics

Q&A for active researchers, academics and students of physics

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, 15) -- locked, unlocked
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 [Locked Date] DESC

Enter Parameters

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