As group is not possible in soql.You can use a map with 'ProductId(product Famil) as key' and value as list of Opportunity Products. --- Map<Id,List<OpportunityLineItem> >.
list<AggregateResult> agresults = [SELECT count(product2id) pid,Product2.family family FROM OpportunityLineItem group by Product2.family]
for (AggregateResult ar : groupedResults) {
System.debug('productids ==:' + ar.get('pid'));
System.debug('family ==:' + ar.get('family'));
}
Hope this helps you! If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
As group is not possible in soql.You can use a map with 'ProductId(product Famil) as key' and value as list of Opportunity Products. --- Map<Id,List<OpportunityLineItem> >.
Map<Id,List<OpportunityLineItem> > opportunityProductMap=new Map<Id,List<OpportunityLineItem> >();.
Hope this will be helpful.
Thanks
Bhargavi.
Try This :
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For SFDC Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1