title: How to update table multiple times based on another table
body: <p>I'm trying to update a table multiple times based on data from another table.<br>
  Below is the table design I have at the moment:</p>
  
  <pre><code>Table A                          Table B
  --------------------             --------------------
  Goods    QTY    Type             Goods    QTY    Type
  Wood      0       R1             Wood       1      R1
  Wood     10       R2             Wood       4      R1
  Glass    10       R1             Wood       5      R1
  Glass     0       R2             Glass      5      R2
                                   Glass      4      R2
  </code></pre>
  
  <p>I would like to do the <strong>addition</strong> on <strong>QTY</strong> in Table A based on <strong>QTY</strong> from Table B, if possible in one update statement.  </p>
  
  <p>Expected output is something like this:</p>
  
  <pre><code>Table A
  --------------------
  Goods    QTY    Type
  Wood     10       R1 ---&gt; Previous value: 0
  Wood     10       R2
  Glass    10       R1
  Glass     9       R2 ---&gt; Previous value: 0
  </code></pre>
  
  <p>I already tried the below update statement to no avail:</p>
  
  <pre><code>UPDATE Table A
  SET A.QTY = A.QTY + B.QTY
  FROM Table A as A JOIN Table B as B ON A.Goods = B.Goods AND A.Type = B.Type
  </code></pre>
  
  <p>However, the above query statement is only updating the first distinct value on Table B. It only update the <code>QTY</code> of <code>Wood</code> to <code>1</code>, and <code>QTY</code> of <code>Glass</code> to <code>5</code>.</p>