Top users by tag and location

1

Please login or register to vote for this query.

(click on this box to dismiss)

With parameters

Stack Apps

Q&A for apps, scripts, and development with the Stack Exchange API

-- Top users by tag and location
-- Currently only looking at score for questions.  Not sure how to fix this yet.

--SELECT TOP 20 * FROM Posts


SELECT us.*,tuser.Score
FROM Users us
JOIN 
(SELECT TOP 100 Answers.OwnerUserId AS UserId, SUM(Answers.Score) AS Score
     FROM Tags 
    JOIN PostTags ON Tags.Id = PostTags.TagId
    JOIN Posts ON Posts.Id = PostTags.PostId  
    JOIN Posts Answers ON Answers.ParentId = Posts.Id 
   WHERE Tags.TagName = '##TagName##'
  GROUP BY Answers.OwnerUserId
ORDER BY SUM(Posts.Score) DESC
) tuser ON tuser.UserId = us.Id
WHERE
lower(location) like '%united states%' or
(lower(location) like '%florida%' 
) 
or
(lower(location) like '%sarasota%' 
)
or
(lower(location) like '%us%' 
and lower(location) not like '%ussr%' )

ORDER BY tuser.Score DESC

Enter Parameters

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