Tag Information

3

Please login or register to vote for this query.

(click on this box to dismiss)

Displays up, down and accepted answers by tag

Ask Ubuntu

Q&A for Ubuntu users and developers

-- Tag Information
-- Displays up, down and accepted answers by tag

DECLARE @UserId int = ##UserId##

Select p.TagName,

p.UpMod,
(IsNull(p.UpMod,0) * 10) as 'UpVoteValue',
p.DownMod,
-(IsNull(p.DownMod,0) * 2) as 'DownVoteValue',
p.AcceptedByOriginator,
(IsNull(p.AcceptedByOriginator,0) * 15) as 'AcceptedValue',
(((IsNull(p.UpMod,0) * 10) - (IsNull(p.DownMod,0)* 2)) + (IsNull(p.AcceptedByOriginator,0) * 15)) as 'TotalReputation'


From
(
SELECT --TOP 20 
    TagName,
    VoteTypes.Name, 
    COUNT(*) AS Votes 
FROM Tags
    INNER JOIN PostTags ON PostTags.TagId = Tags.id
    INNER JOIN Posts ON Posts.ParentId = PostTags.PostId
    INNER JOIN Votes ON Votes.PostId = Posts.Id and VoteTypeId in (1,2,3)
    INNER JOIN VoteTypes on Votes.VoteTypeId = VoteTypes.Id 
WHERE 
    Posts.OwnerUserId = @UserId
GROUP BY TagName, VoteTypes.Name 

)q
Pivot (sum(Votes) for Name in ([UpMod],[DownMod],[AcceptedByOriginator])
)p
Order By 1,2

Enter Parameters

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