Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSofia Eriksson
6,665 PointsShow all SaleDate, SaleAmount, and SalesRep First and Last name from Sale and SalesRep. Make sure that all Sales appear
The full question is: In a car database there is a Sale table with columns, SaleID, CarID, CustomerID, LocationID, SalesRepID, SaleAmount and SaleDate. The database also has a SalesRep table with columns, SalesRepID, FirstName, LastName, SSN, PhoneNumber, StreetAddress, City, State and ZipCode. Show all SaleDate, SaleAmount, and SalesRep First and Last name from Sale and SalesRep. Make sure that all Sales appear in results even if there is no SalesRep associated to the sale.
My code looks like this: SELECT SaleDate, SaleAmount, FirstName, LastName FROM SalesRep LEFT OUTER JOIN Sale ON SalesRep.SalesRepID = Sale.SalesRepID;
But i keep getting this error message:
Bummer: Your query didn't select the SaleDate
, SaleAmount
, FirstName
and LastName
correctly!
1 Answer
Sarat Chandra
4,898 PointsHi Sofia, Remember you need to get all Sales even if there is no SalesRep associated to the sale. But your query gets only such sales that have SalesRep associated. Since it is left outer join it matters which table name you put after FROM. Hope this hint helps!