Activity Score

0

Please login or register to vote for this query.

(click on this box to dismiss)

Code Golf and Coding Challenges

Q&A for programming puzzle enthusiasts and code golfers

DECLARE @UID int = ##UserId##

DECLARE @UpVoteWeight   int = 5
DECLARE @DownVoteWeight int = 8
DECLARE @QuestionWeight int = 25
DECLARE @AnswerWeight   int = 10
DECLARE @CommentWeight  int = 5

SELECT Score = Upvotes   * @UpVoteWeight +
               Downvotes * @DownVoteWeight +
               Questions * @QuestionWeight +
               Answers   * @AnswerWeight +
               Comments  * @CommentWeight,
       Upvotes, Downvotes, Questions, Answers, Comments
FROM (
  SELECT Upvotes, Downvotes,
    (
      SELECT COUNT(*)
      FROM Posts
      WHERE OwnerUserId = @UID and PostTypeId = 1
    ) as Questions,
    (
      SELECT COUNT(*)
      FROM Posts
      WHERE OwnerUserId = @UID and PostTypeId = 2
    ) as Answers,
    (
      SELECT COUNT(*)
      FROM Comments
      WHERE UserId = @UID
    ) as Comments
  FROM Users
  WHERE Id = @UID
) data

Enter Parameters

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