Top users per tag for a location


Please login or register to vote for this query.

(click on this box to dismiss)

Displays total reputation and city

Music Fans Meta

Q&A about the site for music historians, critics, and fans

-- Top users per tag

declare @user_id int = ##UserID##;
declare @limit int = ##Limit##;
declare @tag_id int = (select id from tags where tagname = '##TagName##');

--select rank() over (order by score desc) "Rank", * from (
select top (@limit)
  rank() over (order by sum(answers.score) desc) "Rank"
  , "User Link"
  ,sum(answers.score) as "+1s for tag"
  ,reputation as "Total reputation"
  ,location as "Location"
from users
join posts answers on ( = answers.owneruserid)
join posts parent on (answers.parentid =
join posttags on ( = posttags.postid)
where posttags.tagid = @tag_id
and answers.posttypeid = 2  -- answers only
and LOWER(users.location) LIKE LOWER('%##Location##%')
group by, reputation, location
order by sum(answers.score) desc

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results