Access 2003 で、2 つのクエリを組み合わせて結果の違いを見つけるクエリを作成したいと考えています。
クエリ 1: [すべて]
SELECT mars.Name, mars.Location, mars.Business_Unit
FROM mars
GROUP BY mars.Name, mars.Location, mars.Business_Unit;
それは返す
Name Location Business Unit
----- --------- -------------
John Sydney AU
Grace Brisbane AU
Lee Melbourne GU
クエリ 2: [not_zero]
SELECT mars.Name, mars.Location, mars.Business_Unit
FROM mars
WHERE ((mars.orc)<>0)
GROUP BY mars.Name, mars.Location, mars.Business_Unit;
戻り値:
Name Location Business Unit
----- -------- -------------
John Sydney AU
Grace Brisbane AU
作成しようとしているクエリ:
SELECT m.Name, m.Location, m.Business_Unit
FROM
all AS m
LEFT JOIN
Not_Zero AS o
ON (m.Name=o.Name)
AND (m.Location=o.Location)
AND (m.Business_Unit=o.Business_Unit)
GROUP BY m.Name, m.Location, m.Business_Unit;
クエリで次のことを達成したいと思います:
Name Location Business Unit
---- --------- -------------
Lee Melbourne GU
しかし代わりに、[all] クエリと同じ結果が得られます。
Name Location Business Unit
----- --------- -------------
John Sydney AU
Grace Brisbane AU
Lee Melbourne GU
さて、この [mars] テーブルは次のようなものです。
Name Location Business Unit ORC
----- --------- ------------- ---
John Sydney AU 0
Grace Brisbane AU 5
John Sydney AU 10
Grace Brisbane AU 0
Lee Melbourne GU 0
Lee Paris EU 0
私が達成しようとしているのは、 orc = 0 を持つ名前をずっと取得することです。つまり、たとえば、次のようにします。
Name Location Business Unit ORC
---- --------- ------------- ---
Lee Melbourne GU 0
Lee Paris EU 0