title: SQL - SUM two columns from two tables and write in new Column
body: <p>I have the following situation to solve. I have a Table A with product information and I have a Table B with client purchase history. Now I need to calculate in a new Column "<code>Sum_product_X</code>" the Sum of the frequency of the purchases with the value of the product for each <code>ClientID</code>. So in this case we know A client has bought <code>Product A</code>  5 times, so we need to calculate in the column <code>sum_producta</code> the sum of <code>5 * 5$</code></p>
  
  <pre><code>  Table A (Product Price Table)
      ----------------------------
      ProductA | ProductB | ProductC
  
      5$ | 10$ | 15$         
  
  
  
      Table B (Client purchase history)
      -----------------------
      ClientID | Frequency_ProductA |Frequency_ProductB | Sum_ProductA | Sum_ProductB
  
      Abc123 | 5 | 10 | to be calculated: 5*5 | to be calculated 10*10
  </code></pre>
  
  <p>I need to add that I found out that the SQL support of environment has the following rules:</p>
  
  <blockquote>
    <p>Only SELECT statements to data extension or data views in an account
    or in the parent account Nested Queries UNION JOIN GROUP BY</p>
  </blockquote>
  
  <p>Table A can be modified. Meaning the structure could be as well the following:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Table A 
  -----------------------
  
  Productname | Price
  product A | 5
  product B | 10
  product C | 15</code></pre>
  </div>
  </div>
  </p>