title: Calculating the sum of rows that have been grouped in SQL
body: <p>I have the query:</p>
  
  <pre><code>SELECT substring(Code,1,6) as Code
  From Table
  Group by substring(Code,1,6)
  Order By Code
  </code></pre>
  
  <p>However I'm trying to add a column that is the calculated sum of the rows that have been grouped in this query. Example:</p>
  
  <pre>
  Code    Number
  
  S05080A 20
  
  S05080B 20
  
  S70331A 8
  
  S70331B 4
  </pre>
  
  <p>Would then become:</p>
  
  <pre>
  Code    Sum
  
  S05080  40
  
  S70331  12
  </pre>
  
  <p>Hopefully someone can help me out with this one, would be much appreciated!</p>