Reputation for the last twelve (12) months - other users votes on your posts - total sum

1

Please login or register to vote for this query.

(click on this box to dismiss)

3D Printing Meta

Q&A about the site for 3D printing enthusiasts

declare @UserId int = ##UserId##;
declare @FromDate datetime = DATEADD(year, -1, GetDate());
-- declare @ToDate datetime = Convert(datetime, '##ToDateYYYYMMDD##');
WITH a AS (
SELECT v.PostId, v.VoteTypeId, t.Name, v.CreationDate, v.BountyAmount,
CASE  
    WHEN v.VoteTypeId IN (1) THEN 15
    WHEN v.VoteTypeId IN (2) THEN 10
    WHEN v.VoteTypeId IN (3) THEN -2
    Else 0
END AS Points
FROM Votes v
JOIN VoteTypes t ON v.VoteTypeId = t.Id
WHERE PostId IN (
SELECT Id
FROM Posts
WHERE OwnerUserId = @UserId)
AND v.CreationDate >= @FromDate
-- AND v.CreationDate < @ToDate
)
SELECT SUM(c.ReputationTotal) AS ReputationTotalSum FROM (
SELECT VoteTypeId, Name AS VoteTypeName, Points AS ReputationPerVote, count(*) AS VotesCount, Points * count(*) AS ReputationTotal FROM a
GROUP BY VoteTypeId, Points, Name
)c

Enter Parameters

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