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

Ibrahim Aldossrie
Ibrahim Aldossrie
4,150 Points

join challenge task 3 Bummer your query didn't select even I did

Challenge Task 3 of 5 the task was:

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.

so my answer was :

SELECT FirstName,LastName,SaleAmount From Sale inner join SalesRep on Sale.SalesRepID=SalesRep.SalesRepID GROUP BY Sale.SalesRepID; but it still give me Bummer! Your query didn't select the FirstName, LastName and SaleAmount! i dont know where it did go wrong ?

3 Answers

Kevin Gates
Kevin Gates
15,053 Points

Since it has been a year, here's the correct syntax where you can get the information asked:

SELECT sr.FirstName, sr.LastName, s.SaleAmount
FROM SalesRep AS sr
    INNER JOIN Sale AS s
    ON sr.SalesRepID = s.SalesRepID;
Steven Parker
Steven Parker
231,271 Points

FYI: Explicit challenge or quiz answers without explanation are strongly discouraged by Treehouse and may be subject to redaction (I have seen it done by staff or mods in a few cases).

I think most folks have a better learning experience solving it themselves with a few hints anyway.

Steven Parker
Steven Parker
231,271 Points

You don't need "GROUP BY" here.

Grouping will give you only one row for each sales rep. But what the challenge is looking for is a row for every sale.

One clue is that no aggregate was asked for. Generally, when grouping is used, there will be at least one aggregate function used in the returned data.

Ibrahim Aldossrie
Ibrahim Aldossrie
4,150 Points

thanks that worked, i did use GROUP BY because that what i understand from the task when he said "each Sales rep"

SELECT sr.FirstName, sr.LastName, s.SaleAmount FROM SalesRep AS sr INNER JOIN Sale AS s ON sr.SalesRepID = s.SalesRepID;