Ten users with most gold badges

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select * from (
select 
    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
  from
    users   left outer join
    posts   on users.Id = posts.OwnerUserId
             
  where
  posts.PostTypeId = 2 and location!=''
  group by users.Id,Users.location
  )y
  where y.rn<11

Enter Parameters

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