User A edited the most posts of User B

1

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers

Q&A for Drupal developers and administrators

WITH Raw AS (
  SELECT
    PostHistory.UserId AS EditorUserId,
    Posts.OwnerUserId AS EditedUserId,
    PostHistory.PostId
  FROM PostHistory, Posts
  WHERE
    PostHistory.PostId = Posts.Id
    AND
    PostHistory.PostHistoryTypeId <= 9
    AND
    PostHistory.UserId <> Posts.OwnerUserId
    AND
    PostHistory.UserId > 0
    AND
    Posts.OwnerUserId > 0
  GROUP BY PostHistory.UserId, Posts.OwnerUserId, PostHistory.PostId
)
SELECT
  'site://users/' + CAST(Raw.EditorUserId AS VARCHAR(MAX))
    + '|' + MIN(Editor.DisplayName) AS EditorUser,
  'site://users/' + CAST(Raw.EditedUserId AS VARCHAR(MAX))
    + '|' + MIN(Edited.DisplayName) AS EditedUser,
  COUNT(*) AS Count
FROM Raw, Users Editor, Users Edited
WHERE
  Raw.EditorUserId = Editor.Id
  AND
  Raw.EditedUserId = Edited.Id
GROUP BY EditorUserId, EditedUserId
ORDER BY Count DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results