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 e join PostHistory r on r.PostId=e.PostId where e.CreationDate < r.CreationDate 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)