function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Error on SOQL


       I've write a query on opportunity to see avg amount.

How can i see avg amount of opportunity.


Error:line 1, column 1: Illegal assignment from LIST to LIST


List<Opportunity> lst = [SELECT AVG(Amount) FROM Opportunity];






Try the below code snippet as reference:


AggregateResult[] groupedResults  = [SELECT AVG(Amount)aver FROM Opportunity];



Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 


Hi Navatar,



  Could you explain why are we using "AggregateResult[] groupedResults" instead of collection for quering.

Please Provide me reference links



Jerun JoseJerun Jose

Hey Shravan,


You have to remeber that SOQL is not SQL, so the AVG() function in your query does not work the same way as you would in SQL.


What Ankit posted was using Aggregate functions in a query. Aggregate functions are used to perform operations like sum, avg, count and others. These follow a specific syntax different from a normal SOQL query. You can read more on them at




Jerun Jose