0

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 ?

0

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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