Pages

System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop

In order to avoid System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop, make sure the sub query is limited. If the sub query returns more records, we get System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop exception.