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

Stack Overflow

Q&A for programmers

-- 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 sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached