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(p.id) AS [Tag Posts],
    sum(p.score) AS [Tag Reputation - Questions Only],
    u.Reputation AS [Total Reputation]
FROM
    Users u
inner join posts p on p.ownerUserid = u.id
join posts q on p.ParentId = q.Id
inner join posttags pt on pt.postid = p.id or pt.postid = q.parentid
inner join tags t on t.id = pt.tagid
WHERE
    LOWER(Location) LIKE LOWER('%##location##%')
    and t.tagname='##tagname##'
GROUP BY
    u.id, u.reputation
ORDER BY
    sum(p.score) DESC;
    
    
    --SELECT * from PostTypes
    
--WHERE
    
    /*
SELECT
TOP 10
  *--p.Title AS [Title]
FROM
  Posts answers
inner join posts questions on answers.ParentId = questions.Id
inner join posttags pt on pt.postid = questions.id
inner join tags t on t.id = pt.tagid
WHERE
  answers.PostTypeId = 2 --Answer
  and t.tagname='##tagname##'
  */

Enter Parameters

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