I’m looking for an elegant way (in terms of syntax, not necessarily efficient) to get the frequency distribution of a decimal range.
For example, I have a table with ratings column which can be a negative or positive. I want to get the frequency of rows with a rating of certain range.
– …
– [-140.00 to -130.00): 5
– [-130.00 to -120.00): 2
– [-120.00 to -110.00): 1
– …
– [120.00 to 130.00): 17
– and so on.
[i to j) means i inclusive to j exclusive.
Thanks in advance.
You could get pretty close using ‘select floor(rating / 10), count(*) from (table) group by 1’