title: Join two 2 tables to get sum of each year - SQL Server
body: <p>I have 2 tables below. <strong>Common column is ObjectId.</strong></p>
  
  <p><strong>Table 1</strong>:</p>
  
  <pre><code>    Year  ObjectId G_Amount
     =====  ======== ========-
      2010  1234       5.00
      2010  1234       5.00
      2010  5678      10.00
      2010  5678      20.00
      2010  5678      50.00
      2012  9101       0.00
      2012  1122      70.00
      2012  1122     100.00
  </code></pre>
  
  <p><strong>Table 2</strong>:</p>
  
  <pre><code>    ObjectId   I_Amount
     =========  ===========-
      1234       10.00
      1234       30.00
      5678       15.00
      5678       20.00
      9101       25.00
      9101       35.00
      1122       10.00
      1122        0.00
  </code></pre>
  
  <p>I want to join above 2 table such that the resultset becomes like below. <code>G_Amount</code> (total of <code>g_amount</code> for each year from Table 1) &amp; <code>I_Amount</code> (total of <code>i_amount</code> for each year from Table 2) should be displayed year wise.</p>
  
  <p>Result set:</p>
  
  <pre><code>    Year  G_Amount  I_Amount
      ===== ========  ========-
      2010   90.00     75.00
      2012  170.00     70.00  
  </code></pre>
  
  <p>Can anyone please help?</p>