Suppose I have table with a numeric column called score
.
id | score
-----+-------
1 | 817
2 | 57
3 | 571
4 | 906
5 | 496
6 | 129
7 | 93
... | ...
In standard SQL or Postgresql, how to produce a table of counts by range with these ranges overlapping ?
score_range | count
-------------+-------
0-20 | 9
15-50 | 25
25-* | 597
The case when
solution is inapplicable here as it only returns the first bucket the score belongs to.