blarg blarg - 3 months ago 20
SQL Question

Multiple aggregate functions in HAVING clause

Due to the nature of my query i have records with counts of 3 that would also fit the criteria of having count of 2 and so on. I was wondering is it possible to query 'having count more than x and less than 7' ? How could I write this. Here is my current code.

GROUP BY meetingID
HAVING COUNT( caseID )<4


I'd like something like

GROUP BY meetingID
HAVING COUNT( caseID )<4 AND >2


That way it would only count for exactly 3

Answer
GROUP BY meetingID
HAVING COUNT(caseID) < 4 AND COUNT(caseID) > 2
Comments