title: GROUP BY intervals of integer values
body: <p>I need to sum up linear objects' length and to group them by intervals of several years. I have one table storing my objects like this :</p>
  
  <pre><code>- gid serial NOT NULL, 
  - year INTEGER, 
  - the_geom geometry(MULTILINESTRING) ;
  </code></pre>
  
  <p>I need a result like this:</p>
  
  <pre><code>period          | length
  ----------------+-----------
   2005 - 2014    | 18.6
   1995 - 2004    | 16.1
   1985 - 1994    | 7.6
   1975 - 1984    | 19.0
   1965 - 1974    | 28.2
   1945 - 1964    | 10.2
   before 1945    | 0.1 
  </code></pre>
  
  <p>I can't find out on the Web how to perform this, except by producing each line with a different query and to use <code>UNION ALL</code> to merge them together, which is not so good ...</p>