title: SQL. Combining two queries with aggregate functions and WHERE conditions
body: <p>I am relatively new to SQL and ran into a problem I can't seem to solve. I am using Access and I tried to work something with IIF, but that doesn't help or I don't know how.</p>
  
  <p>I have got 2 queries that work fine on their own, how can I combine them into one? My biggest problem seems to be to me that I have two WHERE statements that I cannot seem to get into one query.</p>
  
  <pre><code>SELECT CODE, SUM(Costs)/SUM(Quantity) AS SIMPLE_COST_BASE 
  FROM Shares 
  WHERE EVENT = 'Buy' 
  GROUP BY CODE;
  </code></pre>
  
  <p>
  
  <pre><code>SELECT CODE, (SUM(Costs) + SUM(DRP_PAY))/SUM(Quantity) AS NORMAL_COST_BASE 
  FROM Shares 
  WHERE EVENT &lt;&gt; 'Sell' 
  GROUP BY CODE;
  </code></pre>
  
  <p>My desired result is a table with three columns. One for CODE, one for the SIMPLE_COST_BASE and a third for NORMAL_COST_BASE</p>