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

0

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 (
select
    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 = p.id
where v.VoteTypeId in (2,3)
and OwnerUserId = @UserId
and p.CommunityOwnedDate is null
group by v.UserId
) as rep

Enter Parameters

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