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

No error in my answer but still tells me i get a wrong answer

The exercise: https://teamtreehouse.com/library/querying-relational-databases/subqueries/subqueries The code:

SELECT * FROM Sale AS s INNER JOIN(SELECT * FROM Customer WHERE Customer.Gender = 'F') AS customer ON s.CustomerID = customer.CustomerID The output:

SaleID  CarID   CustomerID  LocationID  SalesRepID  SaleAmount  SaleDate    CustomerID  FirstName   LastName    Gender  SSN
2   2   2   1   1   25000.0 2015-06-01  2   Shirley Adams   F   111-99-1111
3   1   3   1   2   25000.0 2015-06-01  3   Tasha   Bell    F   444-33-7234
7   9   7   1   3   16250.0 2015-07-05  7   Debbie  Miller  F   778-99-3322
8   8   9   2   5   30999.0 2015-07-05  9   Phoong  Ming    F   990-99-4477
11  12  11  1   1   33750.0 2015-08-06  11  Nicole  Dunn    F   776-33-3377
15  17  14  2   6   27300.0 2015-08-29  14  Sarah   Goldman F   994-99-4444
16  16  16  2   6   42250.0 2015-09-02  16  Amanada Peart   F   321-21-4321
20  20  21  1   1   21500.0 2015-10-10  21  Julia   Molina  F   880-01-0008
23  24  23  1   1   27800.0 2015-10-20  23  Gail    Dickens F   498-09-9876
25  22  24  1   3   27400.0 2015-11-01  24  Hillary Simpson F   987-98-7987
26  29  26  1   2   32000.0 2015-11-05  26  Naomi   Naser   F   888-55-2211 ```

4 Answers

Steven Parker
Steven Parker
231,248 Points

You forgot to say which task you were on.

Okay, so for task 4 you get this message when you run the query:

Bummer! The subquery didn't return all CustomerIDs for people who identify as female (F).

That's a good hint that your subquery shouldn't return "*" but just CustomerID.

Other than that, I think you may be in good shape.

SELECT * FROM Sale AS s INNER JOIN(SELECT Customer.CustomerID FROM Customer WHERE Customer.Gender = 'F') AS customer ON s.CustomerID = customer.CustomerID

WORKED! thanks Steven!

I'll try that and come back with an answer, one second. Thank you for your help!

SELECT CustomerID FROM Sale AS s INNER JOIN(SELECT * FROM Customer WHERE Customer.Gender = 'F') AS customer ON s.CustomerID = customer.CustomerID

New code same error shrug can you try doing it yourself. Maybe I'm doing something wrong here, hmmm.

Btw I also tried s.CustomerID (the first one), didn't work either

Steven Parker
Steven Parker
231,248 Points

It's the subquery that should be restricted to returning the CustomerID column, not the main query.