+ Start a Discussion
Awesome User11Awesome User11 

SOQL Example help

Hello,
I am trying to build out a SOQL Query to filter conditionally on a custom object where each records has an Global Enterprise Account and a HQ Account.
The Global Enterprise is the Account where the HQ and Subsidiaries are umbrellaed under so I would need to see all of the accounts that are specifically associated with the Global Enterprise to be represented in all available opportunities in query.
 
The data is pulled together in a custom object that houses the opportunities that is affiliated, the attached account, and also it’s HQ and/or Global Enterprise.
Example Fields:
Opportunity_Name__c
HQ_Account_Name__c
Global_Enterprise_Name__c
Product_List__c
Owner_Account__c
 
In my query, I need to pulls a listing of all of the Oppportunity_Name__c records where Account A and all of the Opportunity_Name__c records for any opportunity where the Globlal Enterprise Account = Account B.  Also, if there is no Global Account, it pulls only the opportunities for the accounts that have the same HQ Account.
Please help