declare @UserId int = ##UserId## select up + down as To...


Please login or register to vote for this query.

(click on this box to dismiss)



-- Enter Query Title
-- Enter Query Description

declare @UserId int = ##UserId##

select up + down as TotalReputation, up as UpRep, down as DownRep from (
    up = sum(case when VoteTypeId = 2 then
        case when p.ParentId is null then 5 else 10 end
        else 0 end),
    down = sum(case when VoteTypeId = 3 then 2 else 0 end)
from Votes v join posts p on v.postid =
where v.VoteTypeId in (2,3)
and OwnerUserId = @UserId
and p.CommunityOwnedDate is null
group by v.UserId
) as rep

Enter Parameters

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