Top Users by location and tag

0

Please login or register to vote for this query.

(click on this box to dismiss)

Created by samliew (http://stackoverflow.com/users/584192/samuel-liew)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

/*-- Top Users by location and tag
-- Created by samliew (http://stackoverflow.com/users/584192/samuel-liew)
-- Modified by sgryzko 

SELECT
TOP 100 
    u.Id AS [User Link],
    --count(q.id) AS [Number of ##tagname## questions],
    sum(q.score) AS [Reputation - ##tagname## questions Only],
    u.Location AS [Location]
FROM
    Users u
inner join posts q on q.ownerUserid = u.id
inner join posttags pt on pt.postid = q.id
inner join tags t on t.id = pt.tagid
WHERE
    LOWER(Location) LIKE LOWER('%##location##%')
    and t.tagname='##tagname##'
GROUP BY
    u.id, u.Location
ORDER BY
    sum(q.score) DESC;*/
    
SELECT
TOP 100 
    Users.Id AS [User Link],
    sum(Answers.score) AS [Reputation - ##tagname## answers Only],
    Users.Location AS [Location]
FROM Posts AS Answers 
    INNER JOIN Posts AS Questions 
    ON Questions.Id = Answers.ParentId
    
    INNER JOIN Users AS Users
    ON Answers.OwnerUserId = Users.Id
    
    INNER JOIN PostTags 
    ON PostTags.PostId = Answers.ParentId
    
    INNER JOIN Tags
    ON Tags.Id = PostTags.TagId
WHERE
    LOWER(Location) LIKE LOWER('%##location##%')
    and Tags.tagname='##tagname##'
GROUP BY
    Users.id, Users.Location
ORDER BY
    sum(Answers.score) DESC;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results