How often is somebody the top editor?

1

Please login or register to vote for this query.

(click on this box to dismiss)

MathOverflow

Q&A for professional mathematicians

;  with editors_cte as
(
select
  UserId, UserDisplayName,
  COUNT(DISTINCT RevisionGUID) AS CountEdits,
  CAST(CreationDate as Date) AS DateEdits
  FROM PostHistory WHERE (PostHistoryTypeId in (4,5,6))
  GROUP BY UserId, UserDisplayname, CAST(CreationDate as Date)
)
, maxedits_cte as
(
SELECT
  MAX(CountEdits) AS MaxEdits,
  DateEdits
FROM editors_cte
GROUP BY DateEdits
)

SELECT e.UserId AS [User Link], e.UserDisplayName, COUNT(*) as NumberDays
FROM  editors_cte e INNER JOIN maxedits_cte m ON e.DateEdits=m.DateEdits
WHERE e.CountEdits=m.MaxEdits
GROUP BY e.UserId, e.UserDisplayName
ORder BY NumberDays DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results