+ Start a Discussion
nagendra kumar 21nagendra kumar 21 

I need to Query a list of Account which have 1 or more records under a child record under the account using workbench

I need to see the the account which have 1 or more records for X child object. 
Parent - Account 
Child - Account team.
using work bench i need to see the which account have 1 or more records in Account team.
Please help me with query to see the list. 


Thanks,
JLA.ovhJLA.ovh
Start the logic from the child records, this will exclude parent records that don't have any child.
The query can be like this one
select accountid,Account.Name from AccountTeamMember group by accountid,Account.Name

 
Raj VakatiRaj Vakati
You cannt able to get it with Single SOQL query 


Use this apex code
 
List<Account> ParentAcc = [SELECT ID from account where ________]; //Insert criteria here
    List<ID> ParentAccIDs = new List<ID>();
    for(Account acc:ParentAcc)
    {
    	ParentAccIDs.add(acc.id);
    }
    
    //This is a list of the children accounts
    List<Account> ChildAcc = [SELECT ID from account where ID IN : ParentAccIDs];