declare @UserId int = ##UserId## declare @VoteStats tab...

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##

declare @VoteStats table (PostId int, up int, down int, CreationDate datetime)
insert @VoteStats
select
    p.Id,
    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),
    p.CreationDate
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 p.Id, p.CreationDate, p.ParentId
select * from @VoteStats

Enter Parameters

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