3

I have a Salesforce query which is pulling all the necessary columns from Opportunity table. It is something like that

Select o.Opportunity_ID__c, o.LastModifiedDate, o.Opportunity_Currency__c, o.Opportunity_Type__c 
FROM Opportunity o
ORDER BY o.LastModifiedDate ASC

All I need is to add one more column. This column is called "EmployeeNumber" in "User" table.

When I loo at Opportunity fields, there is a lookup which is pulling this data called "Opportunity Owner" field in "Opportunity" table.

I tried couple of sub queries which didn't work. Some of the solutions I have seen on Google search; they say, look for Child Relationships. I did but there is no such a child relationship saying "User" or "Owner" under Opportunity child relationship (I used Eclipse for that)

Can you please help me? Thank you

1 Answer 1

6

Well, User is not a child of opportunity so the subquery won't work.

This will work

Select o.Opportunity_ID__c, Owner.EmployeeNumber, o.LastModifiedDate
FROM Opportunity o ORDER BY o.LastModifiedDate ASC

Here is an article from Salesforce which will give you detailed information: SOQL relationship Queries

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .