Q&A for professionals and students of engineering
select datepart(mm, e.CreationDate) as [month] ,datepart(yyyy, e.CreationDate) as [year] ,count(1) as reopens from PostHistory c join PostHistory e on e.PostId=c.PostId join PostHistory r on r.PostId=c.PostId where c.CreationDate < e.CreationDate and e.CreationDate < r.CreationDate and c.PostHistoryTypeId = 10 -- Close and (e.PostHistoryTypeId = 4 or e.PostHistoryTypeId = 5) -- Edit and r.PostHistoryTypeId = 11 -- Reopen group by datepart(mm, e.CreationDate) ,datepart(yyyy, e.CreationDate) order by datepart(yyyy, e.CreationDate) ,datepart(mm, e.CreationDate)