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

Challenge 2 out of 4 Using Subqueries

SELECT * FROM Sale WHERE SaleAmount IN(SELECT CardID FROM Car WHERE StickerPrice > 30000);

8 Answers

Steven Parker
Steven Parker
231,269 Points

When it says "Include all columns", that's a hint that you probably want to start with "SELECT *". Then my first hint was about matching what you are looking for with what the subquery returns. In this case, the subquery is returning "CarId", so the filter clause should start with "WHERE CarID IN...".

Nice Job. Thanks.

Sorry to boughter you i have already solved it.

Steven Parker
Steven Parker
231,269 Points

I could give a more specific answer if you provide a link to the challenge page, but right off I'd expect that it probably won't be helpful to match a sale amount with a sub query that returns card id's.

You may also want to move this question to the "Databases" category.

You Are right, but i made a mistake because i overlooked database for sql.

Sorry that is a general mistake i made

Steven Parker
Steven Parker
231,269 Points

Were you able to resolve your issue from my hint?

And you can still move the question. Click on the rectangle with 3 dots in it and then select "edit question". From there you should be able to pick the topic.

I will have to give it a try.

Done the category update

Trying to change the query so far no luck.

Steven Parker
Steven Parker
231,269 Points

So what do you have now for the query? And please provide a link to the course page.

Challenge Task 2 of 4

Use a subquery along with IN to list all sales of cars with Sticker Price greater than $30000. Include all columns.

SELECT CarID FROM Sale WHERE SaleID IN(SELECT CarID FROM Car WHERE StickerPrice > 30000);

8 11 10 18 17 16 19 26 31 30