title: SQL (postgresql) query for year extraction and sum
body: <p>I try to collect some simple statistics on a table, let's say the simplified structure is the following:</p>
  
  <pre><code>  ID  |      CREATIONDATE        |    VALUE    |
  ------------------------------------------------
    1   | 2007-01-06 13:54:00.000  |      7      |
    2   | 2007-03-07 15:03:00.000  |      8      |
    3   | 2008-07-02 18:55:00.000  |      12     |
    4   | 2008-09-10 19:12:00.000  |      1      |
    5   | 2010-01-06 13:54:00.000  |      4      |
    6   | 2010-01-07 07:13:00.000  |      5      |
  </code></pre>
  
  <p>I'd like to sum the values based on the year of the creation date, so currently I execute the following:</p>
  
  <pre><code>select extract('year' from i.creationdate) as d1,
         sum(i.value)
    from items i
    group d1
    order by d1;
  </code></pre>
  
  <p>which will output</p>
  
  <pre><code>2007;15
  2008;13
  2010;9
  </code></pre>
  
  <p>Is there any way I can improve the query to have it automatically outputs 0 for the missing 2009 year, even if there is no row in the table with a date in 2009?</p>
  
  <pre><code>2007;15
  2008;13
  2009;0
  2010;9
  </code></pre>