title: Adding a calculated column to a SQL Server query
body: <p>I am attempting to add a column in my query (see bottom) by multiplying two of the columns together and grouping by the item number, but I get the following error: </p>
  
  <blockquote>
    <p>Column 'IV00102.LOCNCODE' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.</p>
  </blockquote>
  
  <p>I am sure this is a simple solution that has been covered on here, but I was unable to find what I was looking for. Any help would be much appreciated</p>
  
  <pre><code> SELECT        
       IV00101.ITEMNMBR, IV00102.LOCNCODE, IV00102.BINNMBR, IV00101.STNDCOST,
       IV00101.CURRCOST, IV00101.USCATVLS_3, IV00101.USCATVLS_4, 
       IV00101.USCATVLS_2, IV00102.QTYONHND, 
       SUM(IV00101.CURRCOST * IV00102.QTYONHND) AS 'CxQ'
   FROM            
       IV00101 
   INNER JOIN
       IV00102 ON IV00101.ITEMNMBR = IV00102.ITEMNMBR
   WHERE
       IV00102.LOCNCODE &lt;&gt; ''
   GROUP BY
       IV00101.ITEMNMBR; 
  </code></pre>