Created by samliew (http://stackoverflow.com/users/584192/samuel-liew)
Q&A for music historians, critics, and fans
-- Top Users by Country and tag -- Created by samliew (http://stackoverflow.com/users/584192/samuel-liew) SELECT ROW_NUMBER() OVER(ORDER BY Location DESC) AS [#], u.Location, count(p.id) FROM Users u inner join posts p on p.ownerUserid = u.id inner join posttags pt on pt.postid = p.id inner join tags t on t.id = pt.tagid WHERE t.tagname='##tagname##' group by u.Location ORDER BY Location DESC;