Question score distribution (grouped)

1

Please login or register to vote for this query.

(click on this box to dismiss)

The distribution of scores on questions

Anime and Manga

Q&A for anime and manga fans

-- Question score distribution (grouped)
-- The distribution of scores on questions

WITH TotalPosts AS (
    SELECT CAST(COUNT(*) AS FLOAT) AS Count
    FROM Posts
    WHERE PostTypeId = 1
),
GroupedPosts AS (
SELECT
    Id,
    CASE
    WHEN Score < 0 THEN '-ve'
    WHEN Score = 0 THEN '00'
    WHEN Score = 1 THEN '01'
    WHEN Score = 2 THEN '02'
    WHEN Score = 3 THEN '03'
    WHEN Score = 4 THEN '04'
    WHEN Score = 5 THEN '05'
    WHEN Score <= 10 THEN '06-10'
    WHEN Score <= 20 THEN '11-20'
    WHEN Score <= 50 THEN '21-50'
    WHEN Score <= 100 THEN '51-100'
    ELSE 'Higher' 
    END AS GroupedScore,
    Score
FROM Posts
WHERE PostTypeId = 1
)
SELECT
    GroupedScore,
    Count(*) AS NumQuestions,
    ROUND( Count(*)/(SELECT Count FROM TotalPosts) *100,3) AS Percentage

FROM GroupedPosts

GROUP BY
    GroupedScore

ORDER BY
    GroupedScore

Enter Parameters

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