List all locked posts


Please login or register to vote for this query.

(click on this box to dismiss)

Lists all currently locked posts, most recent first.

Motor Vehicle Maintenance and Repair

Q&A for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

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

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