Shows how often a user's answers get a specific score. Related to http://odata.stackexchange.com/stackoverflow/q/1930
Q&A for people who love being outdoors enjoying nature and wilderness, and learning about the required skills and equipment
-- 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