title: Splitting SQL Data Into Months
body: <p>I have a Datatable with several hundred rows for this year in it. (MS SqlServer 2k8)</p>
  
  <p>I would like to split this data set out into customer enquiries / Month.</p>
  
  <p>What I have so far is;</p>
  
  <pre><code>Select count(id) As Customers, DatePart(month, enquiryDate) as MonthTotal, productCode From customerEnquiries
  where enquiryDate &gt; '2012-01-01 00:00:00'
  group by productCode, enquiryDate
  </code></pre>
  
  <p>But this then produces a row for each data item. (Whereas I want a row per month for each data item.)</p>
  
  <p>So how do I change the above query, so that instead of getting</p>
  
  <pre><code>1 1 10
  1 1 10
  1 1 11
  1 2 10
  1 2 10
  </code></pre>
  
  <p>...</p>
  
  <p>I get</p>
  
  <pre><code>2 1 10    &lt;-- 2 enquiries for product code 10 in month 1
  1 1 11    &lt;-- 1 enquiries for product code 11 in month 1
  2 2 10    &lt;-- 2 enquiries for product code 10 in month 2
  etc
  </code></pre>
  
  <p>And as a bonus question, is there an easy way of naming each month so the output is Jan, Feb, March instead of 1,2,3 in the month column?</p>