错误: Aggregate query has too many rows > 不需要用子查询

Aggregate query has too many rows for direct assignment, use FOR loop

错误的代码:

 if (query == '' || query == null){
   query = 'SELECT id, name, ownerid, Planned_Visits__c,  Actual_Visits__c, Visits_last_Year__c, ' +
     '  (SELECT AccountId, id, Type, ActivityDate, Visit_Report__c ' +
     '   FROM events WHERE AccountId != null and Type != null and ActivityDate != null and Type = \'Sales Visit\' and Visit_Report__c = TRUE AND  ) ' +
     'FROM Account where owner.IsActive = true ' +
     //'     AND id IN(\'001P000000ZKblDIAT\', \'001P000000ZKboRIAT\', \'001P000000ZKd55IAD\', \'001P000000ZKd5KIAT\', \'001P000000ZKd5UIAT\')' +
     '';
  }

原文地址:https://www.cnblogs.com/yqskj/p/2750127.html