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 trialKian Chakamian
15,410 PointsSQL Subqueries Code Quiz
I have been stuck on part 1 for a long time I I do not know what is wrong. It keeps telling me I am not including all the correct models over 30000
Here is my code:
SELECT StickerPrice, ModelName FROM Model INNER JOIN Car ON Model.ModelId = Car.ModelID WHERE StickerPrice IN (SELECT StickerPrice FROM Car WHERE StickerPrice > 30000)
1 Answer
Steven Parker
231,269 PointsYou wouldn't need to join the "Car" table and also create a subquery with it, and the subquery should probably return an ID of some sort instead of the price. You might also need to select * in the main query.
You probably don't need a join for this challenge at all. I could be more specific if you provide a link to the challenge itself.
Kian Chakamian
15,410 PointsKian Chakamian
15,410 PointsThe Challenge is at Querying Relational Databases/ Subqueries / Subqueries
Steven Parker
231,269 PointsSteven Parker
231,269 PointsWith that info, I tracked the link down to this challenge.
My original suggestion is good, you can have your subquery return "ModelID" for the items with the right price and then test that in the
WHERE
clause. And now I'm sure that you won't need aJOIN
.But now I also see that the challenge asks you to "list all the Model Names ...", which means you also do not need to include the "StickerPrice" in the
SELECT
clause.Kian Chakamian
15,410 PointsKian Chakamian
15,410 PointsI tried it again with your advice and it worked! Thanks a ton.