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 trial

Databases

Get Error Ambiguous Column Name

For task 5/5 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.

I keep getting an error ambiguous column name when I check this answer, I think my code is correct but i am not sure why it isn't working, I have tried it a few different ways.

This is my code SELECT Sale.SaleDate, Sale.SaleAmount, SalesRep.FirstName, SalesRep.LastName FROM Sale LEFT OUTER JOIN Sale ON Sale.SalesRepID = SalesRep.SalesRepID

SQL Error: ambiguous column name: Sale.SaleDate

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

First of all task 5 is

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.

But not what you wrote (it is task 3):

Show the First and Last Name of each sales rep along with SaleAmount from both the SalesRep and Sale tables in one result set.

Your code is correct, but you have a typo:

You typed Sale table twice:

SELECT Sale.SaleDate, Sale.SaleAmount, SalesRep.FirstName, SalesRep.LastName 
FROM Sale 
LEFT OUTER JOIN Sale 
ON Sale.SalesRepID = SalesRep.SalesRepID

Do you see right now that you duplicate FROM Sale and LEFT OUTER JOIN Sale ?

Change that last Sale to SalesRep : it will pass :)

Yes! Thank you so much, I was driving myself crazy over this one.