Suppose I have a table with a numeric column (lets call it \"score\").
I\'d like to generate a table of counts, that shows how many times scores appeared in each ran
In postgres (where || is the string concatenation operator):
||
select (score/10)*10 || '-' || (score/10)*10+9 as scorerange, count(*) from scores group by score/10 order by 1
gives:
scorerange | count ------------+------- 0-9 | 11 10-19 | 14 20-29 | 3 30-39 | 2