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
Shubham SengarShubham Sengar 

SOQL problem 4

Give me a count of  the contacts for an Account Like 123??

SELECT Name,Id (SELECT count() FROM Contact) FROM Account WHERE Name like '%123%'
but its gives error..
Best Answer chosen by Shubham Sengar
William TranWilliam Tran
Something like this should do it:

SELECT count() FROM Contact  WHERE Account.Name like '%123%'

All Answers

Praveen Venkata BPraveen Venkata B

Count doesn't work in inner queries. Please use below query.

Select Account.name, Count(Name) from Contact group by account.name

Please mark it as best answer, if it resolves your issue.

Regards,
Praveen Venkata.

William TranWilliam Tran
Something like this should do it:

SELECT count() FROM Contact  WHERE Account.Name like '%123%'
This was selected as the best answer