Question Single Vote Closures by User & Reason

0

Please login or register to vote for this query.

(click on this box to dismiss)

GIS

Q&A for cartographers, geographers and GIS professionals

WITH superclosures AS
(
SELECT
  ph.Id,
  ph.PostId AS [Post Link],
  u.DisplayName AS CloseUser,
  crt.Name AS CloseReasonType,
  COUNT(v.value) AS VoterCount
FROM PostHistory ph
JOIN Posts p ON p.Id = ph.PostId
JOIN Users u ON u.Id = ph.UserId
JOIN CloseReasonTypes crt ON crt.Id = ph.Comment
CROSS APPLY OPENJSON(ph.Text,'$.Voters') AS v
WHERE PostHistoryTypeId = 10
  AND p.PostTypeId = 1
  AND u.DisplayName <> 'Community'
GROUP BY
  ph.Id,
  ph.PostID,
  ph.Comment,
  u.DisplayName,
  crt.Name
HAVING COUNT(v.value) = 1
)
SELECT
  CloseUser,
  CloseReasonType,
  COUNT(*) AS Closures
FROM superclosures
GROUP BY
  CloseUser,
  CloseReasonType
ORDER BY CloseUser ASC, COUNT(*) DESC

Enter Parameters

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