• soniya koppad
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi  All, I want group record by the  field named Shipment_Status__c  as attached.  I get the error "only aggregate expressions use field aliasing"
Here the controller
public class ContainerGlobalShipmentController{
public Map<String, List<Container__c>> Records { get; set; }
public ContainerGlobalShipmentController() {
 Records = new Map<String, List<Container__c>>();
 Container__c [] results =
[SELECT  Shipment_Status__c status, Pkl__c, PO__c, Invoice__c,Name, Size_in_feet__c, Description__c, 
Bill_of_Lading__c,On_Wharf_Date__c,Sailing__c,ETA__c,Demurrage_begins__c,
Brocker__c,Comments__c,     ID_Container__c,  Consignee__c, Provenance__c
 FROM Container__c WHERE (Departed_to_Wharf_Date__c = NULL OR 
 (Departed_to_Wharf_Date__c =LAST_N_DAYS:5))   
 AND Provenance__c ='FFP FLORIDA'];
 
  for(Container__c result: results) {
     status = (String)result.get('status');
    if(!Records.containsKey(status)) {
      Records.put(status, new Container__c[0]);
    }
    Records.get(status).add(result);
  }
}
}

User-added image