You need to sign in to do that
Don't have an account?

Relationship SOQL Query: Opportunity and User
I'm trying to put together a SOQL query that would pull up the following information:
Part I:
SELECT Name, StageName, CloseDate, Amount, OwnerId,
FROM Opportunity WHERE StageName = 'Closed Won'
AND CloseDate = THIS_MONTH
The part above works, but the problem is that I'm only getting the opportunity owner ID, not the name and I also need to limit output to the records where the owners have a specific role ID.
The two pieces below are the pieces I need to add to the query and it seems that both of them are located on the User object. How do I write the relationship query that incorporates all three?
Part II:
FROM User WHERE UserRoleId = '00E0B000000zEGn'
Part III:
SELECT Username
Part I:
SELECT Name, StageName, CloseDate, Amount, OwnerId,
FROM Opportunity WHERE StageName = 'Closed Won'
AND CloseDate = THIS_MONTH
The part above works, but the problem is that I'm only getting the opportunity owner ID, not the name and I also need to limit output to the records where the owners have a specific role ID.
The two pieces below are the pieces I need to add to the query and it seems that both of them are located on the User object. How do I write the relationship query that incorporates all three?
Part II:
FROM User WHERE UserRoleId = '00E0B000000zEGn'
Part III:
SELECT Username
All Answers
SELECT
Name, StageName, CloseDate, Amount, Owner.Name, Owner.Username, Owner.UserRoleId,
( SELECT Id, UserRole.Name FROM user )
FROM Opportunity
WHERE (StageName = 'Closed Won' AND CloseDate = THIS_MONTH)
This didn't work.
Any help would be most appreciated.