one user reputation

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

DECLARE @UserId int = ##UserId##
select ans_up,ans_down,qs_up,qs_down, ans_up*10+ans_down*(-2)+qs_up*5+qs_down*(-2) AS reputation

from (
SELECT sum(case when Posts.PostTypeId  = 2 and Votes.VoteTypeId=2 
then 1 else null end) as ans_up,
sum(case when Posts.PostTypeId  = 2 and Votes.VoteTypeId=3 
then 1 else null end) as ans_down,
sum(case when Posts.PostTypeId  = 1 and Votes.VoteTypeId=2 
then 1 else null end) as qs_up,
sum(case when Posts.PostTypeId  = 1 and Votes.VoteTypeId=3 
then 1 else null end) as qs_down
FROM Users
    INNER JOIN Posts ON Users.id = Posts.OwnerUserId
    INNER JOIN Votes ON Votes.PostId = Posts.Id
    WHERE Posts.OwnerUserId = @UserId
    ) a

Enter Parameters

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