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
Clayton HilteClayton Hilte 

Parent to Child query: Count number of Accounts with a related Event with Type = to "X"

I am trying to Query to get the COUNT of Accounts that have at least 1 Event related to it that has the Type = 'Meeting - Client'

When I run the below SOQL it still brings back Accounts that DO NOT have any Events related to them. How do I fix this?

SELECT Id, (SELECT Event.Id FROM Account.Events WHERE Event.Type = 'Meeting - Client') FROM Account
WHERE OwnerId = '00530000005eaqR'
Mario PaesMario Paes
This query will give you the accounts that have atleast one event of the Type Meeting - Client

SELECT AccountId, COUNT(Id)
FROM Event
WHERE Type = 'Meeting - Client'
GROUP BY AccountId