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 trialSassafras Finley
13,168 PointsI have no idea why this isn't returning the right amount of rows. Please tell me what I've got wrong here.
I don't know what I'm missing since I cannot see the results.
Sassafras Finley
13,168 PointsI'm sorry. I thought it was supposed to include my code with this question. It's for the final code challenge for the Querying Relational Databases course. My code is as follows: select s.* from sale s inner join (select customerid from customer where gender = 'F') c on s.customerid = c.customerid
The question is: "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."
And my query returns: "Your query didn't return all columns from the Sale table for who's CustomerIDs belong to people who identify as female!"
Gabriel Plackey
11,064 PointsYour subquery is only selecting customerID from Customer, which is then also a column in Sales. Then joining on the CustoemrID which is then the only column in Customer. So user SELECT * will automatically only select everrything from Sales since that's all there is left to select anyways.
1 Answer
Gabriel Plackey
11,064 PointsYou just need to removed the s.
SELECT * FROM sale s INNER JOIN (select customerid FROM customer WHERE gender = 'F') c on s.customerid = c.customerid
Sassafras Finley
13,168 PointsThat worked, but I'm curious. The question specifically says, "Select all columns from the Sale table only." Doesn't your solution select all columns from both the Sale table and the Customer table?
KRIS NIKOLAISEN
54,971 PointsKRIS NIKOLAISEN
54,971 PointsCan you show your SQL and/or identify the task?