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
Sheena QueridoSheena Querido 

Apex Class - Group by Error: Illegal Assignment from List to List

I tried creating a GROUP BY clause in my Apex Class, but I'm getting an error message that Line 9 has Illegal Assignment form List to List

Where Line 9 is: 
customerproducts  = [SELECT Description_for_Invoice__c,TSDF_Approval_Number__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c

Entire Apex Class is: 
public class ExhibitAController {
    public Customer_Pricing__c cust {get;set;}
    public List<Customers_Product_Code__c> customerproducts {get;set;}
        
    public ExhibitAController(ApexPages.StandardController stdController){
    
        this.cust = (Customer_Pricing__c)stdController.getRecord();

        customerproducts  = [SELECT Description_for_Invoice__c,TSDF_Approval_Number__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c
                             FROM Customers_Product_Code__c 
                             where Customer_Pricing__c =:cust.Id
                             GROUP BY Description_for_Invoice__c,TSDF_Approval_Number__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c
                             ORDER BY Category__c, Description_for_Invoice__c, Container_Size__c]
            ; }
}

 
Nayana KNayana K
To use group by query results, you must use AggregateResult. 
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_agg_fns.htm