Q&A for scientists using computers to solve scientific problems
WITH Batches AS ( SELECT DATEADD(mm, DATEPART(mm, Posts.CreationDate)-1, DATEADD(yy, DATEPART(yyyy, Posts.CreationDate)-1900, 0)) as [Date], COUNT(*) as Total, SUM(CASE when Posts.LastEditorUserId is not null then 1 else 0 END) as [Edited] FROM Posts GROUP BY DATEPART(yyyy, Posts.CreationDate), DATEPART(mm, Posts.CreationDate) ) SELECT [Date], Total, Edited FROM Batches ORDER BY Date;