title: sql sum some column when all other columns match
body: <p>I have the following SQL temp table which is a result of an SQL query</p>
  
  <p><img src="https://i.stack.imgur.com/ffL4C.png" alt="enter image description here"></p>
  
  <p>I am trying to SUM columns <code>numitems</code> and <code>ignoreditems</code> where all the other columns match</p>
  
  <p>I tried something like the following query:</p>
  
  <pre><code>SELECT 
      catalogid, 
      sum(numitems), sum(ignoreditesm) 
  FROM ##temporderstable 
  GROUP BY 
      catalogid, supplierid, cname, cprice, cstock, ccode, minstock, pother4
  </code></pre>
  
  <p>I can't seem to get it to work</p>
  
  <p>I get an error </p>
  
  <blockquote>
    <p><em>numitems doesn't belong to the table</em></p>
  </blockquote>
  
  <p>although I can see it when I run the command </p>
  
  <pre><code>select * from ##temporderstable
  </code></pre>