fbpx

Free Salesforce Developers Tutorials >

Chapter 8 - Apex DML and Database Methods >

Count Query | Method in Apex Database Class

Count Query | Method in Apex Database Class

What You’ll Learn


S2 Labs

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

Download Study Material

Get access to exclusive study material for Salesforce Certification and ace your exams!

Download Now

Our Salesforce Certification Courses

Hey there! Glad you made it through our Salesforce Developer Training for beginners . But wait! We've got some high-in-demand Salesforce courses for you to take your Salesforce skills to the next level, making you a desired professional in the Salesforce job market.

Post a Comment

Your email address will not be published. Required fields are marked *