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

What is wrong with this query?

According to the grader, my query is not returning all sales to people with Gender = "F". My results are returning the same exact results as the previous question which asks for the same results. I'm thinking this may be a bug in the grader.

Question 4 of https://teamtreehouse.com/library/querying-relational-databases/subqueries/subqueries

The app doesn't seem to allow linking directly to question 4, sorry.

The query is:

select Sale.* from Sale inner join (select * from Customer where Gender = 'F') as fc on Sale.CustomerID = fc.CustomerID;

2 Answers

Steven Parker
Steven Parker
230,248 Points

Try having your subquery return only the CusomerID's.

In practice, what you did should also work but it appears that the checker pre-tests the subquery directly.

Steven Parker Thanks, that did the trick. I guess only returning the CustomerID in the subquery is more efficient anyway.

select * from Sale inner join (select CustomerID from Customer where Gender = 'F') as fc on Sale.CustomerID = fc.CustomerID;