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

Hello there! I would like some help in this challenge.database

challenge Task 5 of 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 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.

2 Answers

Charles Kenney
Charles Kenney
15,604 Points

The query should look like this for challenge 5:

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

thanks