Only Aggregate Expressions Use Field Aliasing – SOQL Error

Only Aggregate Expressions Use Field Aliasing – SOQL Error

Out of many other errors we encounter, this is one with the SOQL. Many times, when writing SOQL, we face the error – “Only Aggregate Expressions Use Field Aliasing” and we are stuck that what’s happening, everything seems all right to me.

You must be missing a comma in the SOQL between two fields before FROM keyword. 

Aliasing is when you want to give some different name to the column in any SOQL result, but you can only do so in aggregate queries of Salesforce, where you use some aggregate functions like sum(Custom_Field__c), count(Id) or any other similar aggregate function.

Below is a valid SOQL using aggregate function with aliasing. We are trying to give “amountTotal” name to Sum(Amount) column.


[Select Sum(Amount) amountTotal, AccountId from Opportunity group by AccountId];

BUT, because aliasing is not allowed in normal SOQL, that is why below SOQL is considered faulty, and will encounter the error “Only Aggregate Expressions Use Field Aliasing”.


[select id, Name Amount from Opportunity];

You might notice we are missing a comma between Name & Amount field, which is why Salesforce thinks that we are trying to give a different label to Name column in SOQL result but that is not allowed.

If you ever encounter this error in future, look for missing comma between two fields in your SOQL.

Happy coding !! 🙂

Permanent link to this article: https://www.sfdcpoint.com/salesforce/only-aggregate-expressions-use-field-aliasing-soql-error/

7 comments

1 ping

Skip to comment form

    • AMAN TIWARI on September 24, 2020 at 10:44 am
    • Reply

    Thanks for this blog!!
    It was really helpful 🙂

    • Sanju on August 12, 2021 at 1:35 pm
    • Reply

    Thanks for this post and solved my error in seconds

    • Pris on September 16, 2021 at 5:25 pm
    • Reply

    very helpful. fixed my issue

    • Trijit on May 5, 2022 at 1:06 pm
    • Reply

    great ….

    • Neil on May 12, 2022 at 9:39 pm
    • Reply

    Thanks — super helpful!

    • Anshul Sahare on January 24, 2023 at 8:16 pm
    • Reply

    Very Helpfull sir

    • gowthami on May 11, 2023 at 11:37 am
    • Reply

    Thanks for this post….Super helpful!

  1. I enjoyed your wonderful blog.

    Thank you for the very hard work done.

Leave a Reply

Your email address will not be published.