I'm trying to make a boolean selection that returns true only if the tests of the types 0,1,2, have a result greater than or equal to 60. The query does not cause me problems at the syntactic level but I can not get 1 from the result . What am I doing wrong?
SELECT 1
FROM resultTest r JOIN stuCLA s ON s.id = r.id_risultcla_studCLA
WHERE s.matr = '12345'AND r.language= 'ENGLISH' AND r.lvl='B1'AND r.testtype=0 AND r.risult>=60 AND r.id IN
(SELECT r1.id FROM resultTest r1
WHERE r1.language= 'ENGLISH' AND r1.lvl='B1'AND r1.testtype=1 AND r1.risult>=60 AND r1.id IN
(SELECT r2.id FROM resultTest r2
WHERE r2.language= 'ENGLISH' AND r2.lvl='B1'AND r2.testtype=2 AND r2.risult>=60 ))
If you want students who have taken all three levels and never have a score less than 60, then one method is:
SELECT rt.id_risultcla_studCLA
FROM resultTest rt
WHERE rt.language = 'ENGLISH' AND
r.lvl = 'B1'AND
rt.testtype IN (0, 1, 2)
GROUP BY rt.id_risultcla_studCLA
HAVING COUNT(*) = 3 AND MIN(rt.result) >= 60;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.