Only Aggregate Expressions Use Field Aliasing – SOQL Error

Problem :- Only Aggregate Expressions Use Field Aliasing – SOQL Error

Solution :- Sometimes we perform the dynamic query in the apex controller. And create the string of all fields like below.

List<Account> listOfAccount = new List<Account>();
String query = 'SELECT id,Name,Type,AccountNumber,AccountSource From Account';
listOfAccount = Database.query(query);

And foregate to add the comma between two field. And getting above error.

So, just carefully review your query and add the (,) .

HAPPY LEARNING