-- I want to get the counts
SELECT
-- inside the range? count it as index -1, or otherwise attribute the count to the pixel index
CASE WHEN IMDB_Rating BETWEEN 1 AND 9.5
-- active pixel bins for 400 pixels
THEN FLOOR((IMDB_Rating - 1) / 0.02125)::INT
ELSE -1 END AS "keyActive",
-- passive bins for rotten tomatoes
FLOOR((Rotten_Tomatoes_Rating - 0) / 5)::INT AS "keyPassive",
-- aggregate counts
count(*)::INT AS count,
FROM data
-- enforece passive range/extent
WHERE Rotten_Tomatoes_Rating BETWEEN 0 AND 100
GROUP BY "keyActive", "keyPassive"
ORDER BY "keyPassive"