You need to sign in to do that
Don't have an account?
Andrew Aldis
SOQL Query on Activity History
I need to pull a query from SF that pulls in the number of activities related to accounts as a count of the number of records and group it by the account owner. The activity history is a subquery and will not let me aggregate the data. I am also not able to pull the query directly from activities because it says it in not queryable. How can I get this to work?
Select
(SELECT OWNER.Name
FROM ActivityHistories
where (ActivityType = 'Discovery Demo' AND ActivityDate=This_month) OR (ActivityType = 'Discovery Interview' AND ActivityDate=This_Month )
)
From Account
Where Target_Account__c = True OR Target_Prospect__c = True
Select
(SELECT OWNER.Name
FROM ActivityHistories
where (ActivityType = 'Discovery Demo' AND ActivityDate=This_month) OR (ActivityType = 'Discovery Interview' AND ActivityDate=This_Month )
)
From Account
Where Target_Account__c = True OR Target_Prospect__c = True
HI Andrew,
As of my knowledge grouping is not possible for subqueries :( but we can do count
List<Account> acclist = [........query...........];
(acclist[0].AcitivityHistories).size();
What I understood about grouping is - [SELECT OWNER.Name
FROM ActivityHistories
Group by Account.Owner.Name] . Is my understading correct on that ?