The following SOQL
gives me the list of max rows with quantity/product name
but I'm only looking to extract the maximum quantity out of all the records.
Do I need to loop to get that?
SELECT max(Quantity__c) qty, product_name__c FROM Asset_line_item__c
where Id = 'xxxxx'
group by product_name__c
I have tried with AggregateResult
.
AggregateResult[] result = [max(Quantity__c) qty,
product_name__c FROM Asset_line_item__c where Id = 'xxxxx'
group by product_name__c];
Best Answer
You should be able to just use
get('qty')
or evenget('expr0')
.Or if you just want the highest max and felt compelled to use aggregation:
Or, as noted in the comments, just get the single highest value with no aggregation at all.