Q&A for professional and enthusiast programmers
select count(distinct q.Id) from Posts q join PostHistory h on h.PostId = q.Id where ClosedDate is not null -- not duplicate and PostHistoryTypeId=10 and Comment<>'1' -- not locked and isnull((select top 1 PostHistoryTypeId from PostHistory where PostId=q.Id and PostHistoryTypeId in (14,15,35) order by CreationDate desc),0) not in (14,35) -- no upvoted answers and not exists (select 1 from Posts a where ParentId=q.Id and Score>=1) -- no accepted answers and AcceptedAnswerId is null and Score <= 0 -- pending reopen votes and not exists (select 1 from Votes where VoteTypeId=7 and PostId=q.Id) -- no edits since closure to question and not exists (select 1 from PostHistory where PostHistoryTypeId in (4,5) and PostId=q.Id and CreationDate > ClosedDate) -- ...or answers and not exists (select 1 from PostHistory h join Posts a on a.Id=h.PostId where PostHistoryTypeId in (4,5) and a.ParentId=q.Id and h.CreationDate > ClosedDate)