+ Start a Discussion
Keith Stephens 18Keith Stephens 18 

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

Hello All,
I hope someone can help me or point me in the correct direction to solve this error I am getting.
This error is occuring with this line of code I have:
AggregateResult[] AARsA  = [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c
			FROM Account_Procedure_Rate__c  group by CPT_Code__c, Main_Center__c];

I think it is due to it's seems to be bringing back thousands of recs, over 5000.
If I were to do this:
List<SObject> AARs= [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c
		FROM Account_Procedure_Rate__c  group by CPT_Code__c, Main_Center__c];


Would it fix my issue?
I cannot reporduce this in DEV or QA because we do not have that many records in those environments, we just do not keep our environments up to date.
Thanks,
KS
Paul S.Paul S.
Keith - I think you're going to have to build a map.  Using LIMIT and OFFSET (on subsequent queries) won't work because the max OFFSET is 2000.  Being that you're hitting the 2000 row limit, we know you'd need an OFFSET larger than 2000.