title: Postgresql Select count of different value of a column
body: <p>I have a <code>postgresql</code> database with following structure : <code>ID, Date, Name,Classification</code>. The classfication is a foreign key value. It has 3 possible values(lets say C1, C2, C3), Name is a random string.</p>
  
  <p>I want to make a query with counting occurrences of every zone at specific date intervals. I want to make it clear with an example. </p>
  
  <p>Let's say my table data is as follows:</p>
  
  <pre><code>ID      CreateDate       Name     Classification
  ------+-------------+------------+-------------- 
  1       2014-01-01        abc             C1 
  2       2012-01-05        def             C2
  3       2014-01-01        gef             C2
  4       2012-01-01        hjk             C1
  5       2014-01-01        lmn             C1
  6       2013-06-01        opr             C3
  7       2014-01-01        xyz             C1
  8       2013-07-01        www             C3
  </code></pre>
  
  <p>and I want to count the number of classifications in every year. The result set in my example is </p>
  
  <pre><code>2012 1 1 0
  2013 0 0 2
  2014 3 1 0
  </code></pre>
  
  <p>The numbers after the date is the number of occurrences of c1, c2, c3 in each year accordingly. </p>
  
  <p>Hope I was being clear. </p>
  
  <p>EDIT:
   I could manage to count specific classifications with year data with the following query. But i got stuck afterwards.</p>
  
  <pre><code>SELECT COUNT() ,CLASSIFICATION
        ,select count(), classification
               ,extract (year from date_trunc( 'year', CREATEDATE )) as year
           from TABLE_NAME
           group by extract ( year from date_trunc( 'year', CREATEDATE )), CLASSIFICATION
           order by year;
  </code></pre>