SOQL Alias a column

I am wondering how you would do something simple like this in SOQL.

select first_name as name from tableA

I can not find any documentation on Aliasing a column which is very common in all forms of SQL, does anyone know if this is possible?


SOQL has very limited aliasing support. You can alias the table, e.g. SELECT FROM Account a, but that’s of very little use. In most contexts you cannot alias fields.

The one exception is for queries that use aggregations, like SELECT COUNT(Id) recordCount FROM Account allows you to alias the result of the aggregation from it’s default expr0 to recordCount.

This probobly doesn’t do what you’re looking for, and you’ll have to use some sort of transform in apex, middleware, or on the API client (depending on what and how you’re building) to alias columns in non-aggregate use cases.

Source : Link , Question Author : Josh , Answer Author : ca_peterson

Leave a Comment