Get Total Edits per User

1

Please login or register to vote for this query.

(click on this box to dismiss)

Computational Science

Q&A for scientists using computers to solve scientific problems

SELECT 
   ph.Id, ph.UserId
INTO 
   #EditsToMyPosts
FROM 
   PostHistory ph
INNER JOIN Posts p
    ON (p.Id = ph.PostId AND 
        p.OwnerUserId = ph.UserId);

SELECT 
    t.UserId,
    count(t.RevisionGUID) count_edit_action
INTO
  #count_edits_per_user
FROM (
SELECT ph.UserId, ph.RevisionGUID,
       MIN(ph.CreationDate) as CreationDate
  FROM PostHistory ph
  WHERE
       ph.PostHistoryTypeId  in (4,5) AND
       ph.Id NOT IN (SELECT m.Id FROM #EditsToMyPosts m WHERE m.UserId = ph.UserId)
  GROUP BY ph.UserId, ph.RevisionGUID
) t
GROUP BY t.UserId;

SELECT count_edit_action as '#edits', count(*) as 'count'
FROM #count_edits_per_user
GROUP BY count_edit_action;

Enter Parameters

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