title: SumIF Access - Multiple tables
body: <p>I am following the question I asked here: <a href="https://stackoverflow.com/questions/22535665/sumif-in-sql-access">SumIF in SQL Access</a> </p>
  
  <p>I have 3 tables [Broker] , [OPT], [TRS]. [Broker] have 2 fields <code>BRKR_CODE, Status</code> and [OPT] and [TRS] Have 5 same fields <code>BRKR1, BRKR2, Date, COM_BRK1, COM_BRKR2</code></p>
  
  <p><code>OPT.BRKR1</code>, <code>OPT.BRKR2</code>, <code>TRS.BRKR1</code>, <code>TRS.BRKR2</code> are linked to <code>Broker.BRKR_CODE</code> and can be equal.</p>
  
  <p>I want to write this query.... If <code>Broker.Status="Active"</code> then Select <code>Broker.BRKR_CODE</code>
  and then for each <code>Broker.BRKR_CODE</code> (for example "CB") do the Sum of <code>OPT.COM_BRKR1</code> when <code>OPT.BRKR1="CB"</code> + Sum of <code>OPT.COM_BRKR2</code> when <code>OPT.BRKR2="CB"</code>  and  do the Sum of <code>TRS.COM_BRKR1</code> when <code>TRS.BRKR1="CB"</code> + Sum of <code>TRS.COM_BRKR2</code> when <code>TRS.BRKR2="CB"</code></p>
  
  <p>I wrote this code using the answer I got in the previous question... but still have syntax issue... basically I want to have an array with 3 column <code>BRKR_CODE</code>, <code>OPT_Tot</code>, <code>TRS_Tot</code></p>
  
  <pre><code>SELECT Broker.BRKR_CODE,
         Sum(OPT.COM_BRKR1)+ Sum(OPT.COM_BRKR2) AS OPT_Tot,
         Sum(TRS.COM_BRKR1)+ Sum(TRS.COM_BRKR2) AS TRS_Tot
  FROM Broker 
       INNER JOIN  OPT
       ON (Broker.BRKR_CODE = OPT.BRKR2) OR (Broker.BRKR_CODE = OPT.BRKR1)
        INNER JOIN  TRS
       ON (Broker.BRKR_CODE = TRS.BRKR2) OR (Broker.BRKR_CODE = TRS.BRKR1)
  WHERE Broker.Status = "Active"
  GROUP BY Broker.BRKR_CODE
  </code></pre>