Distribution of scores on my answers

11

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

Mathematics

Q&A for people studying math at any level and professionals in related fields

-- 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 = ##UserId##

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 = ##UserId##       -- by you
  GROUP BY score
) AS answers
ORDER BY answers.Frequency DESC, Score

Enter Parameters

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