Reputation averages

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers Meta

Q&A about the site for Drupal developers and administrators

DECLARE @include_new_users INT
SET @include_new_users = ##IncludeNewUsers:int?0##

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

SELECT COUNT(Id) AS [Total Users],
       MIN(Reputation) AS [Minimum],
       MAX(Reputation) AS [Maximum],
       SUM(Reputation) / COUNT(Id) AS [Mean],
       (
           SELECT TOP 1 Reputation
           FROM Users
           WHERE Reputation <> 1
           AND Reputation <> 101
           GROUP BY Reputation
           ORDER BY COUNT(Reputation) DESC
       ) AS [Mode],
       (
           SELECT
           (
               (
                   SELECT MAX(Reputation)
                   FROM
                   (
                       SELECT TOP 50 PERCENT Reputation
                       FROM Users
                       WHERE Reputation <> 1
                       AND Reputation <> 101
                       ORDER BY Reputation
                   ) AS [Bottom Half]
               )
               +
               (
                   SELECT MIN(Reputation)
                   FROM
                   (
                       SELECT TOP 50 PERCENT Reputation
                       FROM Users
                       WHERE Reputation <> 1
                       AND Reputation <> 101
                       ORDER BY Reputation DESC
                   ) AS [Top Half]
               )
           ) / 2
       ) AS [Median],
       STDEVP(Reputation) AS [Standard Deviation]
FROM Users
WHERE Reputation <>
    CASE WHEN @include_new_users = 0
        THEN (SELECT -1)
        ELSE (SELECT 1)
    END

Enter Parameters

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