function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sylvain@RibbonFishSylvain@RibbonFish 

Picklist and Group By

Hi everyone,

I got this query:

Select  PickListField__c, Name  FROM Product2   Group By Name,PickListField__c

if I run this query I got this message:

Field 'PickListField__c' can not be grouped in a query call

If I remove the field from the group by:

Select  PickListField__c, Name  FROM Product2   Group By Name

Error: Field must be grouped or aggregated: PickListField__c

Any ideas how to solve my problem?

THanks

Vinita_SFDCVinita_SFDC

Hello,

We can not use GROUP By clause without including aggregate functions in our query.  GROUP BY is used in conjunction with aggregate functions to group the result-set by one or more columns.

You can use a GROUP BY clause without an aggregated function to query all the distinct values, including null, for an object. Ex:

SELECT commPick__c FROM Contact GROUP BY commPick__c

For further details please refer: http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_groupby.htm