I have this aggregated query which seems to return only 1050 rows but still I am getting a limit exception. This is the APEX query:
AggregateResult[] groupedResults = [SELECT COUNT_DISTINCT(ID) cnt, FISCAL_YEAR(CreatedDate) year, FISCAL_MONTH(CreatedDate) month, Country country
FROM Lead
WHERE Should_Include_in_Marketing_Performance__c = true
GROUP BY ROLLUP(Country, FISCAL_YEAR(CreatedDate), FISCAL_MONTH(CreatedDate))];
This is the actual log:
08:32:42:006 SOQL_EXECUTE_BEGIN [66]|Aggregations:0|SELECT COUNT_DISTINCT(ID) cnt, FISCAL_YEAR(CreatedDate) year, FISCAL_MONTH(CreatedDate) month, Country country FROM Lead WHERE Should_Include_in_Marketing_Performance__c = TRUE GROUP BY ROLLUP(Country, FISCAL_YEAR(CreatedDate), FISCAL_MONTH(CreatedDate))
08:32:46:228 SOQL_EXECUTE_END [66]|Rows:1050
08:32:46:229 EXCEPTION_THROWN [66]|System.LimitException: Too many query rows: 50001
Any ideas why I am hitting the limit?