I am having some trouble building the query I need to return the AccountID from the FamilyAccountDetails table where the Family account has at least one child(a child is where the AccountDetails.AccountID equals the FamilyAccountDetails.AccountID) that has a HoldFlag = 0.
AccountDetails
EntID |HoldFlag|AccountID|StatusFlag
FamilyAccountDetails
EntID|FamilyAccountID|AccountID|StatusFlag
SQL:
Select FD.AccountID, FD.FamilyAccountId
from Test2TMAdvisor5.dbo.FamilyAccountDetails FD
where FD.EnterpriseId = 'TestDan'
and AccountId in (Select AccountId from Test2TMAdvisor5.dbo.AccountDetails AD where Ad.AccountID = FD.AccountId and ad.HoldFlag =0)
1 Answer