title: sql query that groups different items into buckets
body: <p>I am trying to write a query that returns the count of items whose price falls into certrain buckets:</p>
  
  <p>For example if my table is:</p>
  
  <pre><code>item_name | price
  i1        | 2
  i2        | 12
  i3        | 4
  i4        | 16
  i5        | 6
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>range   | number of item
  0 - 10  |  3
  10 - 20 |  2
  </code></pre>
  
  <p>The way I am doing it so far is </p>
  
  <pre><code>SELECT count(*)
  FROM my_table
  Where price &gt;=0
  and price &lt;10
  </code></pre>
  
  <p>then </p>
  
  <pre><code>SELECT count(*)
  FROM my_table
  Where price &gt;=10
  and price &lt;20
  </code></pre>
  
  <p>and then copy pasting my results each time into excel.</p>
  
  <p>Is there an automatic way to do this in an sql query?</p>