Close/Delete Kingdoms

1

Please login or register to vote for this query.

(click on this box to dismiss)

Peasants are closed, knights are deleted, displays number of subjects. Counts binding votes on questions only. Questions that are now deleted are not in sede and are not displayed here.

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT
  ROW_NUMBER() OVER (ORDER BY [Peasants] + [Knights] DESC),
  UserId AS [User Link],
  [Peasants],
  [Knights],
  [Peasants] + [Knights] AS [Size of Kingdom]
FROM (
  SELECT 
    UserId,
    SUM(CASE WHEN PostHistoryTypeId = 10 THEN 1 ELSE 0 END) AS [Peasants],
    SUM(CASE WHEN PostHistoryTypeId = 12 THEN 1 ELSE 0 END) AS [Knights]
  FROM 
    PostHistory h
    JOIN Posts p ON h.PostId = p.Id
  WHERE
    p.PostTypeId = 1
  GROUP BY
    UserId
  ) k
ORDER BY
  [Size of Kingdom] DESC

Enter Parameters

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