Q&A for professional mathematicians
with firstrev_cte AS ( SELECT MIN(ph.Id) AS MinId, p.Id FROM Posts p JOIN PostHistory ph ON ph.PostId=p.Id WHERE ph.Text LIKE '%<##tagName##>%' AND ph.PostHistoryTypeId in (3,6,9) GROUP BY p.Id ), users_cte AS (SELECT PostId AS pid, UserId AS uid, UserDisplayName AS udn FROM PostHistory INNER JOIN firstrev_cte ON PostHistory.Id=MinId) SELECT COUNT(pid) AS Count, uid AS [User Link], udn FROM users_cte GROUP BY uid, udn ORDER BY COUNT(pid) DESC