ok, So the query I would like to solve:
I would like to express the following business rule:
Display the groups (for a particular tutorial (tutorialID) and week (week)) that require additional reviews.
So basically I need to determine the amount of members in a group, I then need to aggregate all the scrum reviews for that week and that group, and see if this amount equals the amount of members in the group. If it does, this means that all members have been reviewed for that week, and therefore does not need to be displayed.
Assumptions: a member can only be reviews once per week.
I've tried the following SQL, however I get the following error Subquery returns more than 1 row
SELECT groupName, g.groupId
FROM `student` s, `group` g
WHERE s.GroupId = g.GroupId
AND s.GroupId IS NOT NULL
AND s.tutorialId = 2
GROUP by s.GroupId
AND s.GroupID = (
SELECT GroupId
FROM student
GROUP BY GroupId
HAVING count(*)> (
SELECT count(*)
FROM scrumreview r, student s
WHERE r.reviewee = s.studentID
GROUP BY GroupId
AND r.week = 5
)
)
Student

scrumreview

group

Your inner query (starting on line 8) returns multiple groupids. The equality operator = compares 1-to-1, but what you want is to compare 1-to-many, which you can do with IN.
So, to fix this, on line 7 change the code from this...
AND s.GroupID = (
...to this:
AND s.GroupID IN (
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With