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
adi salesforceadi salesforce 

How to get the no.of records with different stagenames in opportunity.

Raj VakatiRaj Vakati
Use salesforce aggregate query as shonw below 
Select Count(Id),StageName from Opportunity Group By StageName

Hi adi salesforce,

Use This code for better understanding
List<AggregateResult> aggregateList =  new List<AggregateResult>();
aggregateList = [SELECT Count(Id),StageName From Opportunity Group By StageName];
System.debug('No. Of records per StageName--> '+aggregateList);

Please mark the best Answer if it helps you

adi salesforceadi salesforce
Hi Akshay,
Thank you for responding I have to get this requirement by using map concept  so could you try once and tell me the solution.