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 trialTim Schwab
4,109 PointsMistake in question
On the final step of the final quiz of this course, it asks you to select all the columns from the Sale table, but it only accepts an answer that includes all columns from both columns
2 Answers
Tim Schwab
4,109 PointsHere is the exact question:
In a car database there is a Sale table with columns, SaleID, CarID, CustomerID, LocationID, SalesRepID, SaleAmount and SaleDate and a Customer table with columns, CustomerID, FirstName, LastName, Gender and SSN. Use a subquery as a derived table to show all sales to female ('F') customers. Select all columns from the Sale table only.
Your answer is for the first step of the quiz. I wrote
select Sale.* from Sale inner join (select CustomerID from Customer where Gender = 'F') as women on Sale.CustomerID = women.CustomerID
and it returned this error:
Your query didn't return all columns from the Sale table for who's CustomerIDs belong to people who identify as female!
.
I wrote Sale.* and it successfully returned all the Sale columns, so something is messed up there.
Then I put in this query:
select * from Sale inner join (select CustomerID from Customer where Gender = 'F') as women on Sale.CustomerID = women.CustomerID
.
This succeeded, but it shouldn't have, because the question says "Sale table only".
Chris Seals
4,507 PointsThe query that I wrote that it took looks like this:
SELECT ModelName FROM Model WHERE ModelID IN (SELECT ModelID FROM Car WHERE StickerPrice > 30000);
What query did you write that it accepted all columns back?
Scott Joseph-Smith
4,024 PointsScott Joseph-Smith
4,024 PointsI had the same issue. If I limited it to only columns from the Sales Table it kept telling me I hadn't selected all the customers who identified as female. The table always came up looking correct.
Zachary Betz
10,413 PointsZachary Betz
10,413 PointsI ran into the same issue. It only accepted
SELECT *
notSELECT Sale.*
.