title: using datepart() with the group by command
body: <p>I am beating my head against something that is, I'm sure, very obvious - </p>
  
  <p>I have a bit of SQL code designed to sum the total selling price of each invoice in my store and then organize it by Month.  </p>
  
  <pre><code>select SUM(totalsellingprice) from dbo.tblServiceOrders
  where datepart(MONTH,dbo.tblServiceOrders.datereceived) =12
  </code></pre>
  
  <p>As far as I understand it, that should return the sum of all the totatlsellingprice from month 12 (December). Currently, this query returns </p>
  
  <pre><code>135998.92
  </code></pre>
  
  <p>However, if I then try to put that into a group by to get it to spit it out for all months, the number changes. </p>
  
  <pre><code>select SUM(totalsellingprice) from dbo.tblServiceOrders
  group by datepart(MONTH,dbo.tblServiceOrders.datereceived)
  </code></pre>
  
  <p>And I get this table - </p>
  
  <pre><code> 1 - 110567.70
   2 - 60059.59
   3 - 135998.92
   4 - 63089.22
   5 - 102287.01
   6 - 71088.68
   7 - 149102.10
   8 - 67722.65
   9 - 67122.45
  10 - 64234.82
  11 - 7542.05
  12 - 130461.10
  </code></pre>
  
  <p>There are 12 rows, which sounds good to me (12 months in a year) but the last row is 130461.</p>
  
  <p>How is it possible that row 12 from the second search does not equal what I did in the first search? I feel like I'm missing something obvious but I can't for the life of me figure out what. </p>
  
  <p>Any and all help will be much appreciated!</p>