Votes and Answers by Tag

1

Please login or register to vote for this query.

(click on this box to dismiss)

Audio-Video Production Meta

Q&A for engineers, producers, editors, and enthusiasts spanning the fields of audio, video, and media creation

DECLARE @UserId int = ##UserId?47188##;

SELECT 
    TagName,
    Sum(Case when VoteTypeId = 3 then 0 when VoteTypeId = 2 then 1 else 0 end) AS Upvotes,
    Sum(Case when VoteTypeId = 3 then 1 when VoteTypeId = 2 then 0 else 0 end) AS Downvotes,
    Sum(Case when VoteTypeId = 3 then -1 when VoteTypeId = 2 then 1 else 0 end) AS Score, 
    Count(DISTINCT Posts.Id) AS Answers
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
WHERE 
    Posts.OwnerUserId = @UserId
    AND Posts.CommunityOwnedDate IS NULL
GROUP BY TagName 
ORDER BY Score desc

Enter Parameters

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