I'm using the workbenc to select records having more than one certain related record.

SELECT Count(Id),Person__c FROM Work_Relationship__c group by Person__c having count(Id) > 1.

But I have the folloving error:

EXCEEDED_ID_LIMIT: Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch

If I limit the result to 200 I don't get of course the error.

Is there anyway/work around to solve this ?


Assuming Person__c is a lookup, one solution would be to use rollups. Even if the relationship is Lookup rather than Master Detail, you can simply use free tools like Declarative Lookup Rollup Summaries. This tool even allows you to run a batch to calculate and backfill existing counts. Then you would just change your query to:

SELECT Id FROM Person__c WHERE Work_Relationship_Count__c > 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.