Tags by the count of users whose top tag is it

1

Please login or register to vote for this query.

(click on this box to dismiss)

Blender Meta

Q&A about the site for people who use Blender to create 3D graphics, animations, or games

WITH Raw AS (
  SELECT
    Posts.OwnerUserId AS UserId,
    PostTags.TagId,
    SUM(Score) AS Score
  FROM Posts, PostTags
  WHERE
    Posts.ParentId = PostTags.PostId
  GROUP BY Posts.OwnerUserId, PostTags.TagId
),
Raw2 AS (
  SELECT
    UserId,
    MAX(Score) AS MaxScore
  FROM Raw
  GROUP BY UserId
)
SELECT
  MIN(Tags.TagName) AS TagName,
  COUNT(*) AS Count
FROM Raw, Raw2, Tags
WHERE
  Raw.UserId = Raw2.UserId
  AND
  Raw.Score = Raw2.MaxScore
  AND
  Raw.TagId = Tags.Id
GROUP BY Raw.TagId
ORDER BY Count DESC, Raw.TagId

Enter Parameters

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