Reputation points per month (for answers only)

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gets the reputation points gained by a user, per month, for his answers.

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @UserId int = ##UserId##

SELECT 
    YEAR(Votes.CreationDate) AS Year, MONTH(Votes.CreationDate) AS Month,
    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 Rep
FROM Votes
    INNER JOIN Posts ON Posts.Id = Votes.PostId
WHERE 
    Posts.OwnerUserId = @UserId
GROUP BY
    YEAR(Votes.CreationDate), MONTH(Votes.CreationDate)
ORDER BY
    Year DESC, Month DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results