Median Reputation


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- Enter Query Title
-- Enter Query Description

SELECT avg(t1.reputation) as medianval FROM (
SELECT ROW_NUMBER() OVER (ORDER BY d.reputation) AS RowNum, d.reputation
  FROM users d
   WHERE d.reputation > 101
  -- put some where clause here
) as t1, 
  SELECT count(*) as total_rows
  FROM users d
  WHERE d.reputation > 101
  -- put same where clause here
) as t2
WHERE t1.RowNum in ( floor((total_rows+1)/2), floor((total_rows+2)/2) );

SELECT avg(reputation) AS meanval FROM users
    WHERE reputation > 101;

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results