ms access - SQL. Combining two queries with aggregate functions and WHERE conditions -
i relatively new sql , ran problem can't seem solve. using access , tried work iif, doesn't or don't know how.
i have got 2 queries work fine on own, how can combine them one? biggest problem seems to me have 2 statements cannot seem 1 query.
select code, sum(costs)/sum(quantity) simple_cost_base shares event = 'buy' group code;
select code, (sum(costs) + sum(drp_pay))/sum(quantity) normal_cost_base shares event <> 'sell' group code;
my desired result table 3 columns. 1 code, 1 simple_cost_base , third normal_cost_base
i think should work:
select shares.code, sum(iif([event]<>"buy",[costs]/[quantity],0)) simple_cost_base, sum(iif([event]<>"sell",[drp_pay]/[quantity],0)) normal_cost_base shares group shares.code;
Comments
Post a Comment