Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Keep getting an error.
Hi all again, what would be the correct answer for this one?
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 along with IN to list all sales to female customers. (Gender = 'F') Select all columns.
Steven Parker208,472 Points
When you use "IN" with a subquery to match items, it's important to be sure the subquery is selecting the same kind of item as the one you want to match with. In your example, your subquery is selecting "CustomerID", but the WHERE clause is trying to match it with "SaleID".
Try changing your WHERE clause to match on "CustomerID" to go with what the subquery is selecting.
Ariadna Rodriguez6,274 Points
Here is my solution that passed;
SELECT * FROM Sale WHERE CustomerID IN ( SELECT CustomerID FROM Customer WHERE Gender = "F" );