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

Melita Carty
Melita Carty
14,421 Points

Not sure what I'm doing wrong- Subquery 3 of 4

I feel like my results are correct but I can't pass the challenge. Am I misunderstanding the question?

In a car database there is a Model table with columns, ModelID, MakeID and ModelName and a Car table with columns, CarID, ModelID, VIN, ModelYear and StickerPrice.

Use a subquery along with IN to list all the Model Names with a Sticker Price greater than $30000

SELECT * FROM Sale
WHERE Sale.SaleID IN (
    SELECT Sale.SaleID FROM Sale
    JOIN Customer ON (Customer.CustomerID = Sale.CustomerID)
    WHERE Customer.Gender = 'F')
;

I get "The subquery didn't return all CustomerIDs for people who identify as female (F)."

1 Answer

Hi ! As the errors says it, you should return all the list of all the females costumers first in subquery and then use it to only display the sales related, you can do it this way :

SELECT * FROM Sale
WHERE CustomerID IN (
       SELECT CustomerID FROM Customer
       WHERE Gender = 'F'
);
Melita Carty
Melita Carty
14,421 Points

Thanks Johan! I was overcomplicating it haha.