
7 respostas
A best practice here would be to download the Force.com IDE if you don't already have it, and connect it to your Salesforce.com org. When you do so, you'll see a little, nondescript icon called "salesforce.schema" at the top level. Double click it and you'll find a query builder that can be very helpful in writing queries like this.
In your case, you have written a subquery instead of a relationship query. You write relationship queries when you're looking up (like from opportunity to its parent User), and you write subqueries when you're looking down (like from opportunity to its child opportunity products). So the good news is that the query you need is simpler than you think, just
Select o.Owner.Alias, o.OwnerId, o.FiscalYear, o.CloseDate From Opportunity o