Databases Querying Relational Databases Subqueries Subqueries

Mistake in question

On the final step of the final quiz of this course, it asks you to select all the columns from the Sale table, but it only accepts an answer that includes all columns from both columns

2 Answers

Here is the exact question:

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.

Your answer is for the first step of the quiz. I wrote

select Sale.* from Sale inner join (select CustomerID from Customer where Gender = 'F') as women on Sale.CustomerID = women.CustomerID

and it returned this error:

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

I wrote Sale.* and it successfully returned all the Sale columns, so something is messed up there.

Then I put in this query:

select * from Sale inner join (select CustomerID from Customer where Gender = 'F') as women on Sale.CustomerID = women.CustomerID.

This succeeded, but it shouldn't have, because the question says "Sale table only".

Scott Joseph-Smith
Scott Joseph-Smith
4,024 Points

I had the same issue. If I limited it to only columns from the Sales Table it kept telling me I hadn't selected all the customers who identified as female. The table always came up looking correct.

Zachary Betz
Zachary Betz
10,399 Points

I ran into the same issue. It only accepted SELECT * not SELECT Sale.*.

Chris Seals
Chris Seals
4,440 Points

The query that I wrote that it took looks like this:

SELECT ModelName FROM Model WHERE ModelID IN (SELECT ModelID FROM Car WHERE StickerPrice > 30000);

What query did you write that it accepted all columns back?