Q&A for professional and enthusiast programmers
select * from (
users.Id as UserId,
sum(posts.score) as point,Users.location,ROW_NUMBER() OVER(PARTITION BY Users.location ORDER BY sum(posts.score) desc ) as rn
users left outer join
posts on users.Id = posts.OwnerUserId
posts.PostTypeId = 2 and location!=''
group by users.Id,Users.location