You need to sign in to do that
Don't have an account?
Tobias Letzner 5
Field must be grouped or aggregated: Name ??
Hii,
I want to simply find the number of Contacts linked with each account. So i use aggregate query for this. I want to debug Account name with number of contacts. But it shows "Field must be grouped or aggregated: Name" and i have already group it by accountid.
My query is given below-
list<sobject> totalContactVsAccount=[select count(id) totalContact,accountid,account.name from contact where accountid!=null group by accountid limit 10000];
for(sobject obj:totalContactVsAccount){
system.debug(obj);
}
I want to simply find the number of Contacts linked with each account. So i use aggregate query for this. I want to debug Account name with number of contacts. But it shows "Field must be grouped or aggregated: Name" and i have already group it by accountid.
My query is given below-
list<sobject> totalContactVsAccount=[select count(id) totalContact,accountid,account.name from contact where accountid!=null group by accountid limit 10000];
for(sobject obj:totalContactVsAccount){
system.debug(obj);
}
Hi Tobias Letzner,
When you want to find the field from the aggregate query you have to put that field in the group by clause separated by a comma.
Here I will show you how to do it.
list<sobject> totalContactVsAccount=[select count(id) totalContact,accountid,account.name from contact where accountid!=null group by accountid,Account.name limit 10000];
Now, this query will work and find the account name as well, and if you want more account fileds the put those fields by comma-separated.
if you having a problem then Ask me
Please mark Best Answer If Your Problem Is Solved
thanks, Regards,
Malika Pathak
All Answers
Hi Tobias Letzner,
When you want to find the field from the aggregate query you have to put that field in the group by clause separated by a comma.
Here I will show you how to do it.
list<sobject> totalContactVsAccount=[select count(id) totalContact,accountid,account.name from contact where accountid!=null group by accountid,Account.name limit 10000];
Now, this query will work and find the account name as well, and if you want more account fileds the put those fields by comma-separated.
if you having a problem then Ask me
Please mark Best Answer If Your Problem Is Solved
thanks, Regards,
Malika Pathak
Select Id,SUM(ReleaseAmount__c) from myObj__c Where nObj__c = 'a0DA00000012fbMMAQ' group by Id
That is it. Hope this is what you are looking for
cinema hd (http://www.cinemahdapk.info/)
cinema hd https://cinemahdapk.co/