Databases Querying Relational Databases Subqueries Subqueries

Kate Woodroffe
PRO
Kate Woodroffe
Pro 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
Pro 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
177,523 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
Pro Student 6,685 Points

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

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!

Josh Gabel
Josh Gabel
8,261 Points

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
177,523 Points

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

Josh Gabel
Josh Gabel
8,261 Points

Thanks Steven, I just did that.