You need to sign in to do that
Don't have an account?

only aggregate expressions use field aliasing
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

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); } } }
There is no "group by" in your request.
[SELECT Shipment_Status__c
status,for(Container__c result: results) { status = result.Shipment_Status__c ;
All Answers
There is no "group by" in your request.
[SELECT Shipment_Status__c
status,for(Container__c result: results) { status = result.Shipment_Status__c ;
Compile Error:Error: Compile Error: only aggregate expressions use field aliasing at line 17 column 12
public with sharing class TrainingDealAfterButtonClick{
public string EnteredText{get;set;}
public List<Training_Deal__c>TDlist{get;set;}
public Boolean showsection1{get;set;}
public PageReference SearchResult()
{
line 17--- TDlist = [SELECT Name,Course__r.Course_Name__c,Deal_Risk_Status__c, Discount_Percentage__c,
Fees_Finalised_For_student__c,Fee_paid_by_student__c,Fees_Pending_By_Student__c
Trainer_Appointed__r.First_Name__c FROM Training_Deal__c
WHERE Course__r.Course_Name__c LIKE : '%'+EnteredText + '%'];
if(TDlist.isempty()==true)
{
ApexPages.Message errormessage = new ApexPages.Message(ApexPages.Severity.ERROR,'No Records Found');
ApexPage.addMessage(errormessage);
}
else
{
showsection1=true;
}
return null;
}
}
VFP:
<apex:page controller="TrainingDealAfterButtonClick">
<apex:form>
<apex:ouputlabel style = "font=weight:bold" value ="Enter Course to Search : =">
</apex:outputlabel>
<apex:inputText value = "{!EnteredText}"/>
<apex:commandButton Value="search" action="{!SearchResult}" reRender="block"/>
<apex:pageBlock id="block">
<apex:pageMessages />
<apex:pageBlockTable Value="{!TDlist}" var="pro" rendered="{!showsection1}">
<apex:column><apex:facet name="header"> Name </apex:facet>{!pro.Name}</apex:column>
<apex:column><apex:facet name="header"> Course </apex:facet>{!pro.Course__r.Course_Name__c}</apex:column>
<apex:column><apex:facet name="header"> Deal Risk Status </apex:facet>{!pro.Deal_Risk_Status__c}</apex:column>
<apex:column><apex:facet name="header"> Discount Percentage </apex:facet>{!pro.Discount_Percentage__c}</apex:column>
<apex:column><apex:facet name="header"> Fee Finalised For Student </apex:facet>{!pro.Fees_Finalised_For_student__c}</apex:column>
<apex:column><apex:facet name="header"> Fees Paid By Student </apex:facet>{!pro.Fee_paid_by_student__c}</apex:column>
<apex:column><apex:facet name="header"> Fees Pending by Student </apex:facet>{!pro.Fees_Pending_By_Student__c}</apex:column>
<apex:column><apex:facet name="header"> Trainer Appointed Name </apex:facet>{!pro.Trainer_Appointed__r.First_Name__c}</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
You missed a comma between one of the fields that you are trying to query.
The corrected SOQL statement is as follows: Hope that helps!
Here the Accountcontroller
public with sharing class AccountController{
@AuraEnabled(cacheable=true)
public static List <Account> getAccount(){
List<Account> EmployeeList = [Select Employee Number,Employee Name,Rating,Button from Employee__c limit 10];
if(!EmployeeList.isEmpty()){
system.debug('EmployeeList:'+EmployeeList);
return EmployeeList;
}
return Null;
}
}