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

adi veliman
adi veliman
5,343 Points

Can't get this done! Can someone help me please?:D

I don't know why I can't pass the task!?

Steven Parker
Steven Parker
231,248 Points

Otherwise, we don't know what task you are working on.

And also please show the code from your latest attempt.

adi veliman
adi veliman
5,343 Points

https://teamtreehouse.com/library/querying-relational-databases/subqueries/subqueries here is the link

and here is the code:
SELECT Model.ModelName FROM Model INNER JOIN Car ON Model.ModelID = Car.ModelID WHERE Car.StickerPrice IN (SELECT StickerPrice FROM Car WHERE StickerPrice > 30000)

2 Answers

Steven Parker
Steven Parker
231,248 Points

:point_right: Try using the subquery instead of a join.

You can simplify the entire query a good bit in the process. Here's a few hints:

  • Try creating the subquery to return ModelID
  • You could then use the subquery with IN as part of a WHERE clause
  • Since you won't be using JOIN you also don't need to prefix the fields with the table name
adi veliman
adi veliman
5,343 Points

Thanks for hints! I passed the task but btw what I wrote first time was totally wrong or it wasn't what the task expected from me?