title: SQL Query that Groups Multiple Date Fields
body: <p>I have a table that has several date fields.  For example, in the defects table, I have the following:  dateAssigned, dateCompleted, dateResolved.  I am trying to get a query that summarizes the defects as such:</p>
  
  <pre><code>           | Number Assigned | Number Completed | Number Resolved 
  -----------------------------+------------------+-----------------
    Mar-2011 |      33         |        22        |        33        
    Apr-2011 |      10         |        11        |        22
    May-2011 |      22         |        66        |        46
  </code></pre>
  
  <p>etc</p>
  
  <p>I have come up with the following to no avail:</p>
  
  <pre><code>SELECT year(d.dateAssigned)
        ,month(d.dateAssigned)
        ,COUNT(d.dateAssigned)
        ,COUNT(d.dateCompleted)
        ,COUNT(d.dateResolved)
    FROM defect d
    GROUP BY year(d.dateAssigned), month(d.dateAssigned)
    ORDER BY year(d.dateAssigned), month(d.dateAssigned)
  </code></pre>
  
  <p>This works correctly for summarizing the dateAssigned defects, but not for the others.  I realize this is probably due to the fact I am grouping by dateAssigned, but I dont know how else to do it.</p>
  
  <p>Any help would be appreciated.</p>