Top 200 Users, augmented with Votes/Day, sorted by rep

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

-- Top 200 Users, augmented with Votes/Day, sorted by rep

set nocount on

DECLARE @endDate date
SELECT @endDate = max(CreationDate) from Posts

set nocount off
;

WITH TOP200 AS (
  SELECT TOP 200
     *, CONVERT(int, @endDate - CreationDate) as Days
  FROM
     Users
  ORDER BY
     Reputation DESC
), TOP200Augmented AS (
  SELECT
    Id AS [User Link],
    Reputation,
    Days,
    UpVotes,
    DownVotes,
    CONVERT(float, UpVotes)/Days as UpVotesPerDay,
    CONVERT(float, DownVotes)/Days as DownVotesPerDay
  FROM TOP200
)

SELECT *
FROM TOP200Augmented

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached