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 trialHans Eisenman
1,315 PointsHaving a little trouble with this derived table query. Error I'm getting is just "Bummer: try again!" :-\
This is my first derived table query and I'm not sure what I'm doing wrong. Would appreciate any help.
1 Answer
Steven Parker
231,184 PointsYou don't need to join the entire Customer table here. The instructions say they want only the "Sale" table columns, so the only thing you need from the Customer table is the CustomerID to join on:
SELECT * FROM Sale AS s
INNER JOIN (SELECT CustomerID FROM Customer WHERE Gender = 'F') AS c
ON s.CustomerID = c.CustomerID;
Hans Eisenman
1,315 PointsOk, makes sense. Thank you!
Steven Parker
231,184 PointsHans Eisenman — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!
Hans Eisenman
1,315 PointsHans Eisenman
1,315 PointsHmm, not seeing my code or the quiz question here in this request so I'll just post it here in case you can't see it either:
Assignment: 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 as a derived table to show all sales to female ('F') customers. Select all columns from the Sale table only.
My code: