My Top Voted Answer Rate

2

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @UserId int = ##UserId##

SELECT (
  SELECT CAST(COUNT(Id) AS FLOAT)
  FROM Posts a
  WHERE a.OwnerUserId = @UserId
  AND a.PostTypeId = 2
  AND (Score = (
  SELECT MAX(Score) FROM Posts b WHERE b.ParentId = a.ParentId)))
  /
  (SELECT COUNT(*)
  FROM Posts c
  WHERE c.OwnerUserId = @UserId
  AND c.PostTypeId = 2) * 100 AS [Top Voted Answer Rate];

Enter Parameters

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