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 trialSkylar Gordon
7,943 PointsWhat does this return, if it doesn't return all sales to female customers?
So, I am being told by the computer that this is not correct, as it does not return all columns of the rows in the Sale table that have Customer IDs that belong to female customers. If it doesn't return that, what does it return? Since the challenges won't show you what you queried unless you got it right, I can't actually problem solve this until I have that information. (I did a very similar query in the SQL playground for the last task, and got what I thought I'd get, so not being able to see what this queries is the only reason I can't figure this out.)
ETA code:
SELECT s.* FROM Sale AS s INNER JOIN (SELECT CustomerID FROM Customer WHERE Gender = 'F') AS c ON c.CustomerID = s.CustomerID;
2 Answers
KRIS NIKOLAISEN
54,971 PointsAlthough your query may return the same results the task specifically asks Use a subquery along with IN to list all sales to female customers . It is similar to the previous two tasks.
Josh Gabel
18,414 PointsNot sure if you found a solution or not but the challenge appears to be worded incorrectly. It specifically says:
Select all columns from the Sale table only.
However the accepted result is all columns of the Sale table and the result of the derived table. This query will work:
SELECT s.*, c.CustomerID
FROM Sale AS s INNER JOIN (SELECT CustomerID FROM Customer WHERE Gender = 'F') AS c ON c.CustomerID = s.CustomerID;
Skylar Gordon
7,943 PointsSkylar Gordon
7,943 PointsThe one after it asks we do it as a subquery of a derived table - I managed to do the one with IN.