How to get the records count of the SOQL query execution value into a variable in Salesforce?

How to get the records count of the SOQL query execution value into a variable in Salesforce?

COUNT() in SOQL can be used to get the records count of the SOQL query execution value into a variable in Salesforce.
Sample Code:    public static Integer findAcctCount() {
return [ SELECT COUNT() FROM Account ];
}

Or

Integer i = [ SELECT COUNT() FROM Account ];

Leave a Reply