How do I compare to the Top 100 Most Prolific Editors

0

Please login or register to vote for this query.

(click on this box to dismiss)

Shows the top 100 post editors, where the user was the most recent editor and the post was not his own. And *YOU* in comparison.

Stack Overflow

Q&A for professional and enthusiast programmers

-- Top 100 Most Prolific Editors ans 
-- Shows the top 100 post editors, where the user edited someone else's post 
-- and was the most recent editor.
-- (meaning the results are conservative compared to the actual number of edits).

DECLARE @UserId int = ##UserId##

SELECT CASE WHEN [User Link] = @UserId THEN 'YOU'
ELSE CAST(rank() OVER (ORDER BY TotalEdits DESC) AS varchar) END AS rank
      ,*
FROM (
  (
  SELECT TOP 100
         LastEditorUserId AS [User Link]
        ,COUNT(*) AS TotalEdits
        ,COUNT(CASE WHEN PostTypeId = 1 THEN 1 ELSE NULL END) AS QuestionEdits
        ,COUNT(CASE WHEN PostTypeId = 2 THEN 1 ELSE NULL END) AS AnswerEdits
  FROM   Posts
  WHERE  LastEditorUserId <> OwnerUserId
  GROUP  BY LastEditorUserId
  ORDER  BY TotalEdits DESC
  )
UNION ALL           
  SELECT @UserId
        ,COUNT(*) AS TotalEdits
        ,COUNT(CASE WHEN PostTypeId = 1 THEN 1 ELSE NULL END) AS QuestionEdits
        ,COUNT(CASE WHEN PostTypeId = 2 THEN 1 ELSE NULL END) AS AnswerEdits
  FROM   Posts
  WHERE  OwnerUserId <> @UserId
  AND    LastEditorUserId = @UserId
--  GROUP  BY LastEditorUserId
  ) AS x

Enter Parameters

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