Reputation averages


Please login or register to vote for this query.

(click on this box to dismiss)

Russian Language

Q&A for students, teachers, and linguists wanting to discuss the finer points of the Russian language

DECLARE @exclude_new_users INT = ##ExcludeNewUsers:int?0##

DECLARE @excluded_rep_table TABLE (Rep INT)
INSERT INTO @excluded_rep_table VALUES (1),(101)

DECLARE @rep_table TABLE (Reputation INT)
INSERT INTO @rep_table (Reputation)
    SELECT Reputation
    WHERE Reputation <>
        CASE WHEN @exclude_new_users = 0
        THEN -1
        ELSE (SELECT IIF (EXISTS (SELECT Rep FROM @excluded_rep_table WHERE Rep = Reputation), Reputation, -1))
DECLARE @rep_count BIGINT = (SELECT COUNT(*) FROM @rep_table)

SELECT @rep_count AS [Total Users],
       MIN(Reputation) AS [Minimum],
       MAX(Reputation) AS [Maximum],
       SUM(Reputation) / @rep_count AS [Mean],
           SELECT TOP 1 Reputation
           FROM @rep_table
           GROUP BY Reputation
           ORDER BY COUNT(Reputation) DESC
       ) AS [Mode],
           SELECT AVG(1.0 * Reputation)
               SELECT Reputation FROM @rep_table
               ORDER BY Reputation
               OFFSET (@rep_count - 1) / 2 ROWS
               FETCH NEXT 1 + (1 - @rep_count % 2) ROWS ONLY
           ) AS [Inner Median]
       ) AS [Median],
       STDEVP(Reputation) AS [Standard Deviation]
FROM @rep_table

Enter Parameters

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