I want to create an histogram based on price column values from equipment table.
I know I can count the frequency of prices in an interval I can set, but the problem is that I won't get the ranges with 0 frequency.
so if I want an interval of 200 and the values are:
I will only get the ranges:
0-200, count = 3
400-600, count = 3
as a solution I can write explicitly the ranges, like:
SELECT count(CASE WHEN price>= 0 AND price < 200 THEN 1 END) AS '[0 - 200]', count(CASE WHEN price>= 200 AND price < 400 THEN 1 END) AS '[200 - 400]' ... ... from equipment group by eq_type;
if I want to set multiple ranges, let's say from 0 to 10000 in steps of 200, is there a way I can create an array/series and use it in the query instead of typing 50 rows of the above code?