Flags per user

0

Please login or register to vote for this query.

(click on this box to dismiss)

Magento

Q&A for users of the Magento e-Commerce platform

SELECT
     PostHistory.UserId [User Link] ,
     
     
     SUM(Case 
     when PostHistory.PostHistoryTypeId = 10 then 1
     when PostHistory.PostHistoryTypeId = 11 then 1
     when PostHistory.PostHistoryTypeId = 12 then 1
     when PostHistory.PostHistoryTypeId = 13 then 1
     when PostHistory.PostHistoryTypeId = 14 then 1
     when PostHistory.PostHistoryTypeId = 15 then 1
     when PostHistory.PostHistoryTypeId = 19 then 1
     when PostHistory.PostHistoryTypeId = 120 then 1
     end) as 'summe',
     
     SUM(Case when PostHistory.PostHistoryTypeId = 10 then 1 end) AS 'Close',
     SUM(Case when PostHistory.PostHistoryTypeId = 11 then 1 end) AS 'Reopen',
     SUM(Case when PostHistory.PostHistoryTypeId = 12 then 1 end) AS 'Delete',
     SUM(Case when PostHistory.PostHistoryTypeId = 13 then 1 end) AS 'Undelete',
     SUM(Case when PostHistory.PostHistoryTypeId = 14 then 1 end) AS 'Lock',
     SUM(Case when PostHistory.PostHistoryTypeId = 15 then 1 end) AS 'Unlock',
     SUM(Case when PostHistory.PostHistoryTypeId = 19 then 1 end) AS 'Protected',
     SUM(Case when PostHistory.PostHistoryTypeId = 20 then 1 end) AS 'Unprotected'
FROM PostHistory
WHERE Year(PostHistory.CreationDate) > 2010 and PostHistory.UserId > 0
GROUP BY PostHistory.UserId, PostHistory.UserDisplayName
ORDER BY SUM(Case 
     when PostHistory.PostHistoryTypeId = 10 then 1
     when PostHistory.PostHistoryTypeId = 11 then 1
     when PostHistory.PostHistoryTypeId = 12 then 1
     when PostHistory.PostHistoryTypeId = 13 then 1
     when PostHistory.PostHistoryTypeId = 14 then 1
     when PostHistory.PostHistoryTypeId = 15 then 1
     when PostHistory.PostHistoryTypeId = 19 then 1
     when PostHistory.PostHistoryTypeId = 120 then 1
     end) desc

Enter Parameters

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