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
Harshal GuravHarshal Gurav 

4. Write a query to get the count of all the contact records

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Harshal,

You can simply execute the below query.
 
select count(id) from contact

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
Vishnu YaraVishnu Yara
Hi Harshal Gurav,
 
you can try the following

AggregateResult ar = [select count(id) from contact];

Thanks,