Menu
I’m trying to run a query which will show all students who have a status of 1 (active) and they’re in class type 1 (general role) or if they’re in more than 5 classes.
This is what I have. It works except I get students in 0-5 classes as well. So I guess it doesn’t work.
“`
SELECT s.ID, s.StudentName, (SELECT COUNT(*) AS ttl FROM Classes i WHERE i.StudenID = s.ID) As Qnty
FROM `students` s
WHERE s.StudentStatus= 1 AND s.ClassType = 1 OR (SELECT COUNT(*) AS ttl FROM Classes i WHERE i.StudentID= s.ID) > 5
ORDER BY `Qnty` ASC