I have the following query:
Opportunity opp = [SELECT Id, Name, OwnerID, accountID, CreatedBy from Opportunity where CreatedDate<:Date.today() and CreatedBy.UserRoleId=:Inside_Sales.Id ];
And this is the error I'm receiving:
No such column 'CreatedBy' on entity 'Opportunity'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
I need to make the query so it only looks for opportunities that where created by users with a specific role. How can I use the CreatedBy field in a query?