请有人帮我这个
环境:MS Access 2010,Windows 7
我想连接两个查询
1)特定项目中的活跃人士(她的9)
2)进行最后一次测试
添加1)
SELECT per.perNachname,
per.perMitgliedsnummer,
prm.prmID,
tei.teiangIDRef,
tei.teiperIDRef,
prm.prmpdaIDRef,
prm.prmdegIDRef
FROM ( tblPersonen AS per
RIGHT JOIN tblTeilnahmen AS tei
ON
(per.perMitgliedsnummer=tei.teiperIDRef
AND tei.teiangIDRef = 9)
)
LEFT JOIN
tblPromotionTest AS prm
ON
prm.prmperIDRef=per.perMitgliedsnummer
这有效,但我看到很多行而不是这个我想看到每个人只有最后一次测试的行或者右边没有任何东西,如果这个人没有通过任何测试。 >>>这个想法类似于tblPERSON LEFT JOIN tblTEST<<<
添加2)
SELECT p.prmperIDRef,
p.prmID,
p.prmpdaIDRef,
p.prmdegIDRef
FROM tblPromotionTest AS p
LEFT JOIN tblPromotionTest AS p2
ON (p.prmID < p2.prmID)
AND (p.prmperIDRef=p2.prmperIDRef)
WHERE p2.prmperIDRef Is Null
提前感谢您的支持 亲切的问候Bernhard
我发现以下规避:
SELECT per.perNachname, per.perVorname, per.perMitgliedsnummer, prm.prmID, prm.prmpdaIDRef, prm.prmdegIDRef
FROM tblPersonen AS per LEFT JOIN tblPromotionTest AS prm ON per.perMitgliedsnummer = prm.prmperIDRef
WHERE prm.prmID IN (
SELECT p.prmID
FROM tblPromotionTest AS p LEFT JOIN tblPromotionTest AS p2 ON (p.prmID < p2.prmID) AND (p.prmperIDRef=p2.prmperIDRef)
WHERE p2.prmperIDRef Is Null)
AND per.perMitgliedsnummer IN
(
SELECT tei.teiperIDRef
FROM tblPersonen AS per INNER JOIN tblTeilnahmen AS tei ON per.perMitgliedsnummer = tei.teiperIDRef
WHERE (((tei.teiangIDRef)=9))
)
UNION SELECT per.perNachname, per.perVorname, per.perMitgliedsnummer, prm.prmID, prm.prmpdaIDRef, prm.prmdegIDRef
FROM tblPersonen AS per LEFT JOIN tblPromotionTest AS prm ON per.perMitgliedsnummer = prm.prmperIDRef
WHERE prm.prmID Is Null and per.perMitgliedsnummer IN (SELECT tei.teiperIDRef
FROM tblTeilnahmen as tei
WHERE tei.teiangIDRef=9);