title: Finding the SUM of values of a column of all records in sql 2005
body: <p>I want to find the <em>SUM</em> of values in a column <strong>weight</strong>. I want this sum for all records that are identified with a common value in one of the columns <strong>name</strong>. Further, I want to consider only those records that have a certain value in the column <strong>type</strong>.    <br><br>
                                                                                  name               weight      type<br>
     1     <code>$</code>          12.00        A<br>
     2     <code>$</code>          7.00         B<br>
     2     <code>$</code>         7.00         A<br>
     1     <code>$</code>          1.00         C<br>
     2     <code>$</code>          7.00         B<br>
     1     <code>$</code>          1.00         C<br>
     2     <code>$</code>          7.00         B<br>
     1     <code>$</code>          7.00         B<br>
     2     <code>$</code>         7.00         C<br>
     2     <code>$</code>          7.00         B<br></p>
  
  <p>I want the total weight for name 2, for the types A and B. Can a subquery be written for this or only looping can be done. Tnx.</p>