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 trialTadjiev Codes
9,626 PointsIn a car database there is a Sale table with columns, SaleID, CarID, CustomerID, LocationID, SalesRepID, SaleAmount and
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 the First and Last Name of each sales rep along with SaleAmount from both the SalesRep and Sale tables in one result set.
SELECT firstname, lastname, salesrepid, saleamount
FROM sale sa
INNER JOIN salesRep AS sr
ON saleid = SalesRepID;
It returns ambiguous salesrepid name? What's the problem here?
3 Answers
Steven Parker
231,269 PointsYou're getting close, but the challenge asks for "the First and Last Name of each sales rep along with SaleAmount", it does not ask for the salesrepid.
Also, when you join tables, the ON terms should be something both tables have in common. So here, you'd want to use the SalesRepID in both tables instead of sa.saleid in one of them.
Tadjiev Codes
9,626 PointsAlright Thanks a lot)
SELECT firstname, lastname, saleamount
FROM sale sa
INNER JOIN salesRep AS sr
ON sa.SalesRepID = sr.SalesRepID;
This is okay now
Julian Jaramillo
7,265 PointsHey there, I'm using this query, but it tells me I'm missing the IN keyword. Could you please tell me what am I missing? Thanks
Steven Parker
231,269 PointsStart a fresh question and show your exact code in it. You may want to take a look at this video about Posting a Question.
Laura Dumitru
9,818 PointsSELECT sa.SaleDate, sa.SaleAmount, sr.FirstName, sr.LastName FROM Sale sa LEFT OUTER JOIN SalesRep sr ON sa.SalesRepID = sr.SalesRepID;
Steven Parker
231,269 PointsFYI: According to a moderator, explicit answers without any explanation are strongly discouraged by Treehouse and may be subject to redaction.
Tadjiev Codes
9,626 PointsTadjiev Codes
9,626 PointsActually It shsould be with sa. and sr. But doesn't seem to be correct yet.
I takes too long time to load these challenges exactly in this part sometimes gives correct and sometimes wrong. Mailed to Treehouse help to fix it