UpVotes per Answer ratio per Tag

0

Please login or register to vote for this query.

(click on this box to dismiss)

Moderators

Q&A for community managers, administrators, and moderators

-- How many average upvotes per answer for each tag do I have


DECLARE @UserId int = ##UserId##

select A.TagName, A.Answers, B.UpVotes, (1.0*B.UpVotes/A.Answers) as [Ratio]
from (
SELECT --TOP 20 
    TagName,
    COUNT(*) 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 and VoteTypeId = 2
WHERE 
    Posts.OwnerUserId = @UserId
GROUP BY TagName 

) A
inner join (
SELECT --TOP 20 
    TagName,
    COUNT(*) AS UpVotes 
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 = 2
WHERE 
    Posts.OwnerUserId = @UserId
GROUP BY TagName 
) B on A.TagName = B.TagName
where A.Answers > 20
order by B.UpVotes desc

Enter Parameters

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