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.
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.
SELECT CODE, SUM(Costs)/SUM(Quantity) AS SIMPLE_COST_BASE
FROM Shares
WHERE EVENT = 'Buy'
GROUP BY CODE;
SELECT CODE, (SUM(Costs) + SUM(DRP_PAY))/SUM(Quantity) AS NORMAL_COST_BASE
FROM Shares
WHERE EVENT <> 'Sell'
GROUP BY CODE;
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