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

Alain De La Cuadra
Alain De La Cuadra
21,890 Points

select FirstName, LastName,saleAmount,saleDate from Sale left outer join SalesRep on Sale.SalesRepId = SalesRep.SalesRep

challange 5/5 Querying Relational database

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,saleAmount,saleDate from Sale left outer join SalesRep on Sale.SalesRepId = SalesRep.SalesRep

I got i bummer i please help

3 Answers

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 of challenge https://teamtreehouse.com/library/querying-relational-databases/joining-table-data-with-sql/join-queries 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.

In order to solve your query you have to follow the order specified in the task:

  • SaleDate
  • SaleAmount
  • FirstName
  • LastName

In your case as you see order is wrong, so the query should look like this:

SELECT Sale.saleDate, Sale.saleAmount, SalesRep.firstName, SalesRep.lastName
FROM Sale LEFT OUTER JOIN SalesRep 
ON Sale.salesRepId = SalesRep.salesRepId

I also added id at the very end of query SalesRep.SalesRepId.

Make sure you check markdown cheatsheet when post question. It is right below the window where you type question.

And always provide link to challenge.

The easier to reproduce the error you have the faster and easier will it be to help you.

Still having trouble with that... what did you mean about the order being wrong?

It still keeps telling me: Bummer: You're missing the INNER keyword

Sean Walcott
PLUS
Sean Walcott
Courses Plus Student 5,506 Points

I'm not receiving a correct response with what you provided.

Fernando Discua Jr.
PLUS
Fernando Discua Jr.
Courses Plus Student 5,561 Points

This one took a while BUT I think the order of the answer threw some folks off. Here's what I got after re-reading the question.

SELECT SalesRep.firstName, SalesRep.lastName, Sale.saleAmount FROM Sale INNER JOIN SalesRep ON Sale.salesRepId = SalesRep.salesRepID;

cheers,