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.

Yash Patel
1,751 PointsDERIVED Subquery to find all Female customer sales data (under Challenge Task)
This is Challenge Task #4 for SQL Querying Relational Databases
SELECT * FROM Sale AS s
INNER JOIN (SELECT * FROM Customer WHERE Customer.Gender = "F")
AS f
ON s.CustomerID = f.CustomerID;
What am I doing wrong?

Yash Patel
1,751 Points4 Answers

Joshua Hardy
17,317 PointsSELECT * FROM sale AS s
INNER JOIN (SELECT customerid FROM customer WHERE gender = 'F') AS c
ON s.customerid = c.customerid;
On the inner join, I am selecting customerid and you are selecting all.

Steven Parker
220,378 PointsThis gets the right rows, but with much more data than expected.
The challenge is expecting your subquery to select only the customer ID's from the Customers table, not all the columns.

Yash Patel
1,751 PointsChanging that worked, thanks!
Can you clarify why having all the columns wouldn't work considering all the Males were filtered out?

Steven Parker
220,378 PointsThat "Select all columns from the Sale table only." is your clue. Your current subquery would also give you every column from the Customers table, which is not what the challenge expected to see.

nolan emirot
2,826 PointsIf we specify all the columns instead of "*" it won't work but it's correct...
Joshua Hardy
17,317 PointsJoshua Hardy
17,317 PointsDo you have a link to the task?