2

Is there any way to Group By part of string in SOQL.

For example something like:

Select Id, Name from Object__c group by Name.substringBetween('.','.')

So query by part of a string field and not the whole field.

The other approach that can be taken to this is to create a formula field that takes the substring between the name field, and then use that field in the group by, if there is no other option.

Thanks in advance.

1
  • Is that my answer serves your purpose? Sep 11, 2017 at 21:37

1 Answer 1

8

If you really want to use specific field values in GROUP BY then create a text field and update the text field either by workflow rule or Process builder or trigger.

Formula field is not supported in Group By clause.

There is an idea Allow SOQL GROUP BY on formula fields posted, you could vote for this idea.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .