คิดเป็นรายเดือน ไม่จำเป็นต้องใช้ทุกตาราง
s by month.It is not neccessary to use all the tables.
 FlagTypes:  Id [ number]  Name [ text]  Description [ text] 
SELECT TIME_TO_STR(e.CreationDate, '%M') AS "month", TIME_TO_STR(e.CreationDate, '%Y') AS "year", SUM(CASE r.PostHistoryTypeId WHEN 10 THEN 1 ELSE 0 END) AS Closed, SUM(CASE r.PostHistoryTypeId WHEN 11 THEN 1 ELSE 0 END) AS reopen FROM PostHistory AS e JOIN PostHistory AS r ON r.PostId = e.PostId WHERE e.CreationDate < r.CreationDate AND (e.PostHistoryTypeId = 4 OR e.PostHistoryTypeId = 5) AND r.PostHistoryTypeId IN (10, 11) GROUP BY TIME_TO_STR(e.CreationDate, '%M'), TIME_TO_STR(e.CreationDate, '%Y') ORDER BY TIME_TO_STR(e.CreationDate, '%Y'), TIME_TO_STR(e.CreationDate, '%M')