-2
有沒有更簡單的方法...?查詢太長,除了
SELECT clid, cldoel, clanker, clprefix, clleerlijn, f1, f2, f3, f4 FROM Clusters
WHERE clleerlijn like 'WJNLLUI%' AND (f3 IS NOT NULL OR f4 IS NOT NULL)
AND clid in(
Select agClid FROM agenda2 as a JOIN evaluaties2 as e ON a.agclid = e.evalclid and agLkrid = evallkrid
WHERE (agSchoolid='18' and agDatum >= '2013/01/01' and agDatum <= '2013/02/12')
GROUP BY agClid
except
(SELECT agClid
FROM agenda2 as a
JOIN evaluaties2 as e
ON a.agclid = e.evalclid and agLkrid = evallkrid
WHERE agSchoolid='18'
and agLkrid in (1,2932,2935)
and agDatum >= '2013/01/01'
and agDatum <= '2013/02/12'
AND evalWaarde = 3
GROUP BY agclid
HAVING COUNT(DISTINCT agLkrid) = 3)
)
使用聯接而不是子查詢和'except'子句可能會縮短它,但實際上你所擁有的並不是那麼長。 – iamnotmaynard 2013-02-12 17:28:33