Shows how often a user's answers get a specific score. Related to http://odata.stackexchange.com/stackoverflow/q/1930
Q&A about the site for students, teachers, and linguists wanting to discuss the finer points of the Italian language
-- 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