Q&A for professional and enthusiast programmers
DECLARE @UserId int = ##UserId## SELECT CAST(SUM(CASE WHEN VoteTypeId = 1 THEN 15 -- Accepted answer. WHEN VoteTypeId = 2 AND PostTypeId = 2 THEN 10 -- Upvoted answer. WHEN VoteTypeId = 3 THEN -2 -- Downvote. WHEN VoteTypeId = 9 THEN BountyAmount -- Earned Bounty. END) AS Float) / CAST((SELECT COUNT(*) FROM Posts WHERE Posts.PostTypeId = 2 AND Posts.OwnerUserId = @UserId) AS Float) AS AveragePerAnswer FROM Votes INNER JOIN Posts ON Posts.Id = Votes.PostId WHERE Posts.OwnerUserId = @UserId