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.
Can't have more than 1 column in subquery (but he told us we could?!) sales by gender question.
SELECT s.SaleID, s.CarID, s.CustomerID, s.LocationID, s.SalesRepID, s.SaleAmount, s.SaleDate FROM Sale AS s INNER JOIN (SELECT CustomerID, Gender FROM Customer) AS c ON c.CustomerID = s.CustomerID WHERE c.Gender = 'F';
Error: Can't have more than 1 column in the subquery
Andrew Chalkley said we can't use multiple columns when using IN, but we can if we're joining an Aliased table.
I've tested this by adding the Gender column and removing the WHERE clause. My code produces the correct output.
Does anyone know why I get this error?
Steven Parker221,291 Points
The challenges often have specific validation criteria, sometimes more implicit than explicit in the instructions. For example, when it asks for "all rows" from a table, it's generally expecting you to use the "*" shorthand instead of listing individual columns.
And while your multi-column solution does technically get the job done, the challenge is looking for a solution that uses a single-column derived table. You can easily accommodate this by moving your
WHERE clause into the subquery.
Yeah, turns out it just wants you to ignore the question and return the extra column.
Thanks for your help