Average answer's (reputation / popularity) ratio for a given user

1

Please login or register to vote for this query.

(click on this box to dismiss)

Physics

Q&A for active researchers, academics and students of physics

-- What is the average answer's (reputation / popularity) ratio for a given user ? 

DECLARE @UserId int = ##UserId##

SELECT 
  COUNT(a.id) AS Answers,
  SUM(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END) AS Accepted,
  SUM(a.Score) AS Score,
  SUM(q.ViewCount) AS Views,
  ROUND(SUM( (CAST(a.Score AS float) / CAST(q.ViewCount AS float)) * 100) / COUNT(a.id), 3) as [Average Ratio]
  
FROM Posts a
  INNER JOIN Posts q ON q.Id = a.ParentId

WHERE a.PostTypeId = 2
  AND a.OwnerUserId = @UserId

Enter Parameters

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