function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sindhu NagabhushanSindhu Nagabhushan 

Get induvidual field values from map

map<id,aggregateresult> accmap=new map<id,aggregateresult>([select account__r.id,avg(nps__c)np,avg(Average_Score__c)avs from feedback__c where createddate=this_quarter and account__c=:accex group by account__r.id]);

This is my query.
I want to read the value of avg(nps__c) for a particular account and store that value in a new field.
How do i refer to that field?
I tried something like ar.np  but it does not work


Thanks in advance
kiranmutturukiranmutturu
accmap.get(accountid).get('expr0') or  accmap.get(accountid).get('np') ... You should pass the accountid to get the respective aggregated result.