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
SFDC_EvolveSFDC_Evolve 

Account & Task

How find all the account which are having Task related to them... . 

 

Query must be formed on the Account Object .  . :)

 

Please help :)

Scott_VSScott_VS

Account to Task is a parent-to-child relationship, so you can't call on Task in your WHERE clause to filter for Accounts with Tasks assigned to them. You could use this query:

SELECT AccountId FROM Task GROUP BY AccountId HAVING COUNT(Id) > 0]

 to pull up a list of all Accounts with Tasks assigned to them.

Jia HuJia Hu
try this,

List<Account> acclist = [Select Id, Name From Account Where LastActivityDate != null];
System.debug(' ---------------- ' + acclist );
craigmhcraigmh

Out of curiosity, why must it be querying the Account object? Are there more parts to the query than just the Task requirement?