Q&A for cartographers, geographers and GIS professionals
WITH postclosures AS ( SELECT ph.PostId AS [Post Link], u.DisplayName AS CloseUser, 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 = 10 AND p.PostTypeId = 1 GROUP BY ph.PostID, ph.Text, ph.Comment, u.DisplayName ) SELECT TOP 10 CASE WHEN VoterCount = 5 THEN '5 Votes' WHEN VoterCount < 5 AND CloseUser <> 'Community' THEN 'Super Vote' WHEN VoterCount < 5 AND CloseUser = 'Community' THEN 'Community Vote' ELSE '???' END AS CloseType, COUNT(*) AS Closures FROM postclosures GROUP BY CASE WHEN VoterCount = 5 THEN '5 Votes' WHEN VoterCount < 5 AND CloseUser <> 'Community' THEN 'Super Vote' WHEN VoterCount < 5 AND CloseUser = 'Community' THEN 'Community Vote' ELSE '???' END