title: How to Get Sum of One Column Based On Other Table in Sql Server
body: <p>I have 2 table in my database (like this):</p>
  
  <pre><code>tblCustomers:
  
  id    CustomerName
  1     aaa
  2     bbb
  3     ccc
  4     ddd
  5     eee
  6     fff
  </code></pre>
  
  <hr>
  
  <pre><code>tblPurchases:
  
  id    CustomerID    Price
  1     1             300
  2     2             100
  3     3             500
  4     1             150
  5     4             50
  6     3             250
  7     6             700
  8     2             30
  9     1             310
  10    4             25
  </code></pre>
  
  <p>Now I want with "Stored Procedures" take a new table that give me the sum of price for each customer. Exactly like under.</p>
  
  <p>How can do that?</p>
  
  <pre><code>Procedures Result:
  
  id    CustomerName    SumPrice
  1     aaa             760
  2     bbb             130
  3     ccc             750
  4     ddd             75
  5     eee             0
  6     fff             700
  </code></pre>