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
sgsssgss 

Write a SOQL query to retrieve sum of all closed Opportunity amount for current fiscal year. Store this information in a map with key as year and value as sum of amount. Iterate this map to display statistics

Can anyone help me with this?

Write a SOQL query to retrieve sum of all closed Opportunity amount for current fiscal year. Store this information in a map with key as year and value as sum of amount. Iterate this map to display statistics.
Raj VakatiRaj Vakati
Use this code
 
List<AggregateResult> agg = [SELECT  SUM(Amount) ,CALENDAR_YEAR(CreatedDate) 
                             FROM Opportunity
                             WHERE CALENDAR_YEAR(CreatedDate) != 2018 Group by  CALENDAR_YEAR(CreatedDate)] ;
Map<Integer , Decimal> sumtoYear = new Map<Integer,Decimal>() ;
for(AggregateResult a : agg){
    sumtoYear.put((Integer)a.get('expr1') ,(Decimal) a.get('expr0'))  ; 
}
System.debug('sumtoYear'+sumtoYear);

 
mahesh kumar 330mahesh kumar 330
Write a SOQL QUERY on case object
1.how manycases​​cases closed from last one year
pratiksha mogal 6pratiksha mogal 6
public static void OppAmount(){
   List<AggregateResult> aggr = [select CALENDAR_YEAR(CloseDate) Year,SUM(Amount) Amount from Opportunity
           where CloseDate = THIS_FISCAL_YEAR group by CALENDAR_YEAR(CloseDate)];
       map<Integer,Decimal> Sumofamount = new map <Integer,Decimal>();
         System.debug(aggr);
        }