Regional User Rank

0

Please login or register to vote for this query.

(click on this box to dismiss)

0 for userid means all users

SharePoint

Q&A for SharePoint enthusiasts

-- Regional User Rank 
-- 0 for userid means all users

DECLARE @UserId int = ##UserId##

;WITH regionalranking 
     AS (SELECT u.reputation, 
                u.displayname, 
                u.location, 
                u.id, 
                Rank() OVER (PARTITION BY u.location ORDER BY u.reputation DESC) 
                rk 
         FROM   users u) 
SELECT rk, 
       reputation, 
       location, 
       displayname 
FROM   regionalranking 
WHERE  ( id = @UserId 
          OR @UserId = 0 ) 
ORDER  BY location, 
          rk 

                

Enter Parameters

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