Distribution of scores on my answers (forked)

1

Please login or register to vote for this query.

(click on this box to dismiss)

Shows how often a user's answers get a specific score. Related to http://odata.stackexchange.com/stackoverflow/q/1930

Stack Overflow

Q&A for professional and enthusiast programmers

-- Distribution of scores on my answers
-- Shows how often a user's answers get a specific score. Related to http://odata.stackexchange.com/stackoverflow/q/1930

DECLARE @totalAnswers DECIMAL
SELECT @totalAnswers = COUNT(*) FROM posts WHERE posttypeid = 2 AND owneruserid = 11742502

SELECT score AS AnswerScore, Occurences,
  CASE WHEN Frequency < 1 THEN '<1%' ELSE Cast(Cast(ROUND(Frequency, 0) AS INT) AS VARCHAR) + '%' END AS Frequency
FROM (
  SELECT score, COUNT(*) AS Occurences, (COUNT(*) / @totalAnswers) * 100 AS Frequency
  FROM posts
  WHERE posttypeid = 2                 -- answers
    AND owneruserid = 11742502       -- by you
  GROUP BY score
) AS answers
ORDER BY answers.Frequency DESC, Score

Enter Parameters

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