Experience Salesforce

Count Query | Method in Apex Database Class

What You’ll Learn

  • County Query

countQuery(String str)

Returns the number of records that a dynamic SOQL query would return when executed.

Example countQuery Method In Database Class

Integer i = Database.countQuery(‘SELECT Count() FROM Account’);
System.debug(i);

Note:

countQuery will not work if we enter any field inside the count.

count() // ok
count(ID) // error

salesforce marketing cloud CTA
Next Topic

Need Extra Support? Our FREE study materials have got you covered.

Our expert-prepared study materials provide the answers you need. Clear your doubts and improve your skills with detailed notes from industry professionals.

cts-img
Rakshabandhan Sale