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 trialCross Ender
9,567 PointsFor some reason, this is not working.
I run it, and I get a glitched error message:
'a0dcbce9-f6e8-452d-9243-5692da754ecd.rb:41:in eval': undefined method
shift' for "SQL Error: no such column: modelname":String (NoMethodError) from a0dcbce9-f6e8-452d-9243-5692da754ecd.rb:41:in eval' from a0dcbce9-f6e8-452d-9243-5692da754ecd.rb:41:in
'
1 Answer
Katie Wood
19,141 PointsHi there,
You're close! I believe the error was coming from this part:
WHERE ModelName IN ( SELECT ModelName FROM Car WHERE StickerPrice > 30000 )
Here, your current query is asking for ModelName IN a selection where there is no ModelName - Car doesn't have that column. If you switch ModelName with Car.ModelId, it works. Also, make sure you add DISTINCT - I noticed the challenge doesn't pass you if there are duplicate values in the list.
I broke it up a little to make it a bit easier to read, but the final query would look something like this:
SELECT DISTINCT
ModelName
FROM
Model
INNER JOIN Car
ON Car.ModelID = Model.ModelID
WHERE
Car.ModelId IN ( SELECT ModelId FROM Car WHERE StickerPrice > 30000 );
Hope this helps!
Cross Ender
9,567 PointsCross Ender
9,567 PointsThe challenge is at https://teamtreehouse.com/library/querying-relational-databases/subqueries/subqueries My Code: SELECT ModelName FROM Model INNER JOIN Car ON Car.ModelID = Model.ModelID WHERE ModelName IN ( SELECT ModelName FROM Car WHERE StickerPrice > 30000 );