我試圖製作一張表,顯示扒手的AVG在市場區和AVG的扒手在沒有市場的地區。1個表中的2個不同的AVG列與選擇
我想有這樣的輸出:
district with market | district without market
----------------------------------------------
269 | 34
而是我得到這個:
district with market | district without market
----------------------------------------------
269 | 269
34 | 34
這是我使用的查詢:
select round(avg(average),0) as districts_with_markets, round(avg(average),0) as districts_without_markets
from zakkenrollerij
where wijk in (select district
from market)
union
select round(avg(average),0) as districts_with_markets, round(avg(average),0) as districts_without_markets
from zakkenrollerij
where wijk not in (select district
from market)
希望有人可以幫助我:D