Question Reopens by Vote Counts

1

Please login or register to vote for this query.

(click on this box to dismiss)

Moderators

Q&A for community managers, administrators, and moderators

WITH postreopens AS (
SELECT
  ph.PostId AS [Post Link],
  u.DisplayName AS OpenUser,
  COUNT(v.value) AS VoterCount
FROM PostHistory ph
JOIN Posts p ON p.Id = ph.PostId
JOIN Users u ON u.Id = ph.UserId
CROSS APPLY OPENJSON(ph.Text,'$.Voters') AS v
WHERE PostHistoryTypeId = 11
  AND p.PostTypeId = 1
GROUP BY
  ph.PostID,
  ph.Text,
  ph.Comment,
  u.DisplayName
)
SELECT
  CASE 
    WHEN VoterCount = 5 THEN '5 Votes'
    WHEN VoterCount = 1 AND OpenUser <> 'Community' THEN 'Super Vote'
    WHEN VoterCount < 5 AND OpenUser <> 'Community' THEN 'Super Vote with Others'
    WHEN VoterCount < 5 AND OpenUser = 'Community' THEN 'Community Vote'
    ELSE '???'
  END AS OpenUser,
  COUNT(*) AS Reopens
FROM postreopens
GROUP BY
  CASE 
    WHEN VoterCount = 5 THEN '5 Votes'
    WHEN VoterCount = 1 AND OpenUser <> 'Community' THEN 'Super Vote'
    WHEN VoterCount < 5 AND OpenUser <> 'Community' THEN 'Super Vote with Others'
    WHEN VoterCount < 5 AND OpenUser = 'Community' THEN 'Community Vote'
    ELSE '???'
  END
ORDER BY 1

Enter Parameters

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