Monday, January 27, 2014

Will below query work? Explain. SELECT COUNT(Id), Name, Address__c FROM Opportunity GROUP BY Name

Will below query work? Explain.

SELECT COUNT(Id), Name, Address__c FROM Opportunity GROUP BY Name

Above query will throw an error.
Explanation : In Group by clause the columns selected must be either used in Group by clause or in aggregate functions. The Name field is neither used in aggregate methods and in group by clause and hence will result in error “Malformed Query”.



No comments:

Post a Comment