If I say

SELECT count(id), field_one__c, field_two__c 
   WHERE field_once__c > 1 AND field_two__c < 6 
   GROUP BY field_one__c, field_two__c

could I have it only return groups where the size is more than 1? I understand there is a having clause, but I do not believe it works with 'where'

  • 4
    What makes you say 'having' doesn't work with 'where'? What's the actual query that's not working for you? Are you getting any errors when combining having and where?
    – Nick Cook
    Mar 17 at 3:03

1 Answer 1


The HAVING clause works perfectly fine for this requirement. Just remember it goes after GROUP BY.

SELECT ... FROM ... WHERE ... GROUP BY ... HAVING count(Id) > 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.