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 trial

Databases Querying Relational Databases Subqueries Subqueries

Kate Woodroffe
PLUS
Kate Woodroffe
Courses Plus Student 6,685 Points

Stuck on task 4 of querying relational databases, sub queries assessment

I'm stuck on task 4 of the subquery section of querying relational databases. I have input the code code and I feel like it's right (I've tested equivalent code in SQL playground with the library tables). What is wrong?

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.

My answer is

select s.saleid,s.carid,s.customerid,s.locationid,s.salesrepid,s.saleamount,s.saledate from sale s inner join (select customerid from customer where gender = 'F') c on s.customerid = c.customerid;

Kate Woodroffe
Kate Woodroffe
Courses Plus Student 6,685 Points

The error received was

Bummer: Your query didn't return all columns from the Sale table for who's CustomerIDs belong to people who identify as female!

4 Answers

Steven Parker
Steven Parker
231,265 Points

You're very close! But when they say "show all sales", they mean all columns ("SELECT *") from the sales. Just use the wildcard instead of naming individual columns and you'll pass.

Kate Woodroffe
Kate Woodroffe
Courses Plus Student 6,685 Points

Thank you. I thought I'd tried that but must have tried s.* instead.

Carolyn Yon
Carolyn Yon
2,705 Points

Wow...I had this same issue. The course does not seem to be consistent because when it used the language "show all sales" in a previous exercise, I used the individual column names and it passed. Then in an earlier module when it said "show all..." and I used the "*", it wouldn't pass. Thanks for the post though!

I had this same issue. The Challenge text specifically says

Select all columns from the Sale table only.

Someone should adjust the challenge text to reflect the query result the challenge is actually looking for.

Steven Parker
Steven Parker
231,265 Points

You might want to report that as a bug directly to the staff as described on the Support page.

Thanks Steven, I just did that.