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
ss kumarss kumar 

I have a requirement I want to Count all total case records and count of Which case status was New


I have a requirement I want to Count all total case records and count of Which case status was New
Best Answer chosen by ss kumar
Arun Kumar 1141Arun Kumar 1141

Hi ss,

To count the total number of Case records and the number of Case records with the status "New" in Salesforce, you can use a SOQL query.

Integer totalCases = [SELECT COUNT() FROM Case];
Integer newCases = [SELECT COUNT() FROM Case WHERE Status = 'New'];

System.debug('Total Cases: ' + totalCases);
System.debug('New Cases: ' + newCases);
Hope this will be helpful.
Thanks!

 

All Answers

VinayVinay (Salesforce Developers) 
Hi Kumar,

You can use SOQL query on case to get total case records.
Select Id from case
Select Id from case where status=new

https://developer.salesforce.com/forums/?id=906F0000000DDBWIA4
https://salesforce.stackexchange.com/questions/361657/how-to-write-soql-query-in-salesforce-to-get-total-row-record-counts-of-each-obj

Please mark as Best Answer if above information was helpful.

Thanks,
Arun Kumar 1141Arun Kumar 1141

Hi ss,

To count the total number of Case records and the number of Case records with the status "New" in Salesforce, you can use a SOQL query.

Integer totalCases = [SELECT COUNT() FROM Case];
Integer newCases = [SELECT COUNT() FROM Case WHERE Status = 'New'];

System.debug('Total Cases: ' + totalCases);
System.debug('New Cases: ' + newCases);
Hope this will be helpful.
Thanks!

 

This was selected as the best answer