All Votes per tag

0

Please login or register to vote for this query.

(click on this box to dismiss)

Enter Query Description

Music Fans

Q&A for music historians, critics, and fans

-- Enter Query Title
-- Enter Query Description


with tagBadge AS 
(
       SELECT 
           name,
           count(id) badge_count
       FROM
           badges
       GROUP BY 
          name
)
, metrics as (
 
SELECT 
    ROW_NUMBER() OVER (ORDER BY COUNT(Tags.id) DESC) rank,
    TagName,
    COUNT(Tags.id) AS UpVotes,
    badge_count


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
    LEFT JOIN tagBadge ON Tags.TagName = tagBadge.name
WHERE 
  Posts.CommunityOwnedDate IS NULL
GROUP BY TagName ,badge_count
) 
SELECT 
rank,
tagname,
upvotes,
badge_count,
cast(badge_count as decimal(10,2))  / cast(upvotes as decimal(10,2)) as badgesperupvote
From metrics

Enter Parameters

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