You need to sign in to do that
Don't have an account?
Mario C
Grouping Fields in SOQL Query
The following query fetches the latest checkout date for each property among all products with status 'booked'.
The query returns the max date and related property ID. Is there a way to fetch the product ID (OpportunityLineItem ID) too? Unfortunatelly, if I add the Id to the query, I must also group by the Id field.
The query returns the max date and related property ID. Is there a way to fetch the product ID (OpportunityLineItem ID) too? Unfortunatelly, if I add the Id to the query, I must also group by the Id field.
SELECT MAX(End_Date_Time__c) latestCheckOut, Property__c Property FROM OpportunityLineItem WHERE OpportunityId = :oli.OpportunityId AND Status__c = 'booked' GROUP BY Property__c
Raj Vakati
If group by OpportunityLineItemid will not work then you need to write custom code to get the aggigate values