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 trialYash 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
231,271 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
231,271 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?