apex – SOQL aggregate query issue with number fields
I was trying built aggregate query on number field, Found an strange behaviour.
Object Considered: Campaign
I have used Visual Code for execute SOQL for my analysis.
Use Case 1:
NumberOfContacts -> Standard Salsforce Number Field : Number(9, 0)
sfdx force:data:soql:query –query SELECT NumberOfContacts, COUNT(Id) FROM Campaign GROUP BY NumberOfContacts
Querying Data… done
NUMBEROFCONTACTS COUNT(ID)
──────────────── ─────────
0 1
Total number of records retrieved: 1.
Use Case 2:
NumberSent -> Standard Salsforce Number Field : Number(18, 0)
sfdx force:data:soql:query –query SELECT NumberSent, COUNT(Id) FROM Campaign GROUP BY NumberSent
Querying Data… done
ERROR running force:data:soql:query:
COUNT(Id) FROM Campaign GROUP BY NumberSent
^
ERROR at Row:1:Column:54
field ‘NumberSent’ can not be grouped in a query call
Use Case 3:
TestNumberField__c -> Custom Number Field : Number(9, 0)
sfdx force:data:soql:query –query SELECT TestNumberField__c, COUNT(Id) FROM Campaign GROUP BY TestNumberField__c
Querying Data… done
ERROR running force:data:soql:query:
COUNT(Id) FROM Campaign GROUP BY TestNumberField__c
^
ERROR at Row:1:Column:69
field ‘TestNumberField__c’ can not be grouped in a query call
Question is why i am able run aggregate query on number standard number field which has length of 9, and unable to do on custom number field and standard number field which has length 18.
Is this a limitation of Salesforce ?
Read more here: Source link