Q&A for SharePoint enthusiasts
DECLARE @userid int = ##user## SELECT COUNT(*) AS Edits4Badges FROM ( SELECT CAST(CreationDate AS SMALLDATETIME) AS foo, PostID FROM PostHistory ph WHERE PostHistoryTypeId IN (4,5) AND PostId NOT IN ( SELECT p.Id FROM Posts p WHERE p.OwnerUserId = ph.UserId ) AND UserID = @userid GROUP BY CAST(CreationDate AS SMALLDATETIME), PostID ) AS bar