I have a table with two columns meetingID and caseID. The meetingIDs can be from one of three categories, so I use a subquery to select a particular one by returning only the meetingIDs from another table that match that category.
Once I have this list of meetingIDs I want to count how many of them have two caseIDs. I also need to exclude a few caseIDs from the count, but that's irrelevant for now.
Here's the code I have so far;
SELECT COUNT( meetingID ) , meetingID FROM case_meeting WHERE meetingID IN ( SELECT DISTINCT a.meetingID FROM case_meeting a INNER JOIN meeting b ON a.meetingID = b.meetingID WHERE b.categoryID = '1' ) GROUP BY meetingID HAVING COUNT( caseID ) =2 The main problem I have is actually writing code that will successfully count the number of meetingIDs that have two caseIDs instead of returning a list of them.
at the moment the code is returning a list where the number of rows matches the figure i want and in each row is a '2'
2is the value of theCOUNT()ormeetingID? The query seems to be logically and syntactically correct.