My rank among all users ordered by total reputation

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drones and Model Aircraft Meta

Q&A for experienced flyers, pilots, and builders of drones and model aircraft

declare @tot integer = (select count(*) from users)

;with users_ranked as (
select 
  RANK() OVER(ORDER BY u.Reputation DESC) AS rnk,
  NTile(100) OVER(ORDER BY u.Reputation DESC) AS ntile,
  u.id AS uid,
  u.Reputation rep 
FROM Users u 
)

SELECT 
  'You',
  r.rnk AS [Rank],
  r.ntile,
  convert(decimal, r.rnk) / @tot * 100.0 perc,
  r.uid AS [User Link],
  r.rep AS [Reputation]
FROM users_ranked r
WHERE r.uid = ##userid##
UNION ALL
SELECT 
  'Community',
  r.rnk,
  r.ntile,
  convert(decimal, r.rnk) / @tot * 100.0 ,
  r.uid,
  r.rep
FROM users_ranked r
ORDER BY 1 DESC, r.rep DESC

Enter Parameters

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