Tags where a user is in top X answerers


Please login or register to vote for this query.

(click on this box to dismiss)

Earth Science

Q&A for those interested in the geology, meteorology, oceanography, and environmental sciences

VotesByTagAndUser as (
select   Tags.Id TagId
       , Posts.OwnerUserId UserId
       , sum(Posts.Score) Score
  from Tags
       inner join PostTags ON PostTags.TagId = Tags.id
       inner join Posts ON Posts.ParentId = PostTags.PostId
 where Posts.CommunityOwnedDate is null
 group by Tags.Id
     , Posts.OwnerUserId
VotesByTagAndUserWithRank as (
select   vtu.TagId
       , vtu.UserId
       , rank() over (partition by vtu.TagId order by vtu.Score desc) Position
       , vtu.Score
  from VotesByTagAndUser vtu
select   t.TagName
       , u.DisplayName UserName
       , vtu.Position
       , vtu.Score
  from VotesByTagAndUserWithRank vtu
       inner join Tags t on t.Id = vtu.TagId
       inner join Users u on u.Id = vtu.Userid
 where vtu.UserId = ##UserId##
   and vtu.Position <= ##TopX##
   and vtu.Score != 0
 order by vtu.Position, t.TagName

Enter Parameters

Switch to meta site
loading Hold tight while we fetch your results