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 trialOdessa Winter
1,295 PointsWhy is my query returning model that sold for less than 30000
This query returns models that sold for less than 30000 because the same model ID has multiple sales. How do I filter this down?
2 Answers
Steven Parker
232,381 PointsA model may have multiple sales, but each model will have only one sticker price.
Which step are you working on, and what is the exact query you entered?
Odessa Winter
1,295 PointsI'm working on question 1 of the subquery code challenges. However, when looking at the Cars table in the playground, there are multiple sales prices for the same modelID. For example the impala has 2 sales - 28000 and 32000. My query is returning all sales - even those below 30k.
SELECT m.modelname, c.stickerprice FROM model AS m INNER JOIN Car as c ON m.modelid = C.modelid WHERE c.modelid IN (Select modelid FROM car WHERE stickerprice > 30000);
Steven Parker
232,381 PointsSteven Parker
232,381 PointsThe challenge only asks you to list the Model Names, you won't need to JOIN here. Also, the challenge is only concerned with sticker price, sale prices (and the entire sales table) won't be used.