How many votes do I receive per answer?

1

Please login or register to vote for this query.

(click on this box to dismiss)

On average, how many upvotes do I receive for each answer I give?

Stack Overflow

Q&A for programmers

-- How many votes do I receive per answer?
-- On average, how many upvotes do I receive for each answer I give?

DECLARE @UserID int = ##UserId##;

WITH VotesOnPosts AS (
SELECT v.Id AS VoteId
, p.Id AS PostId
, p.PostTypeId AS PostTypeId
, p.OwnerUserId AS UserId
, vt.Name AS VoteTypeName
FROM Votes v
INNER JOIN Posts p ON v.PostId = p.Id
INNER JOIN VoteTypes vt ON v.voteTypeId = vt.Id
)
, Answers AS (SELECT OwnerUserId AS UserId, Id AS PostId FROM Posts WHERE PostTypeId = 2)
, Counts AS (
SELECT
(SELECT COUNT(*) FROM VotesOnPosts WHERE VoteTypeName = 'UpMod' AND UserId = @UserID AND PostTypeId = 2) AS TotalUpVotes,
(SELECT COUNT(*) FROM Answers WHERE UserId = @UserID) AS TotalAnswers
)
SELECT TotalUpVotes, TotalAnswers, (CAST(TotalUpVotes AS float) / TotalAnswers) AS VotesPerAnswer FROM Counts

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached