<p>Suppose I have a table with a numeric column (lets call it "score").</p>

<p>I'd like to generate a table of counts, that shows how many times scores appeared in each range.</p>

<p>For example:</p>

<pre>
score range  | number of occurrences
-------------------------------------
   0-9       |        11
  10-19      |        14
  20-29      |         3
   ...       |       ...
</pre>

<p>In this example there were 11 rows with scores in the range of 0 to 9, 14 rows with scores in the range of 10 to 19, and 3 rows with scores in the range 20-29.</p>

<p>Is there an easy way to set this up?  What do you recommend?</p>

```
```
create table scores (
   user_id int,
   score int
)

select t.range as [score range], count(*) as [number of occurences]
from (
      select user_id,
         case when score >= 0 and score < 10 then '0-9'
         case when score >= 10 and score < 20 then '10-19'
         ...
         else '90-99' as range
     from scores) t
group by t.range
```
```