Accepted Answer Statistics (II)

1

Please login or register to vote for this query.

(click on this box to dismiss)

Shows user's: * total answer count * accepted answer count * upvoted/zero-voted/downvoted answer counts

SharePoint

Q&A for SharePoint enthusiasts

-- Accepted Answer Statistics

DECLARE @UserId int = ##UserId##

SELECT
 Count(*) AS [All],
 Sum(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END) AS [Accepted],
 Sum(CASE WHEN a.Score > 0 THEN 1 ELSE 0 END) AS [Upvoted],
 Sum(CASE WHEN a.Score = 0 THEN 1 ELSE 0 END) AS [Zero Voted],
 Sum(CASE WHEN a.Score < 0 THEN 1 ELSE 0 END) AS [Downvoted]
FROM
 Posts a
  LEFT JOIN 
   Posts q
    ON q.AcceptedAnswerId = a.Id
WHERE
 a.OwnerUserId = @UserID AND
 a.PostTypeId = 2

Enter Parameters

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