我想在 Access 2003 中创建一个查询,它结合了两个查询来查找结果之间的差异。
查询一:[全部]
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