Answer stats

1

Please login or register to vote for this query.

(click on this box to dismiss)

Reverse Engineering Meta

Q&A about the site for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation

DECLARE @UserId int = ##UserId##
;

SELECT TOP 50
    TagName,
    COUNT(distinct answer.Id) as answers,
    SUM(case when Votes.VoteTypeId = 2 then 1
             when Votes.VoteTypeId = 3 then -1
        end) AS Score,
    SUM(case when Votes.VoteTypeId = 2 then 1 end) AS Upvotes,
    SUM(case when Votes.VoteTypeId = 3 then 1 end) AS Downvotes,
    SUM(case when Votes.VoteTypeId = 1 then 1 end) AS Accepted
FROM Tags
    INNER JOIN PostTags ON PostTags.TagId = Tags.id
    INNER JOIN Posts answer ON answer.ParentId = PostTags.PostId
    LEFT JOIN Votes ON Votes.PostId = answer.Id
WHERE 
    answer.OwnerUserId = @UserId
    AND answer.CommunityOwnedDate IS NULL
GROUP BY TagName 
ORDER BY Score DESC

Enter Parameters

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