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

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,143 Points

What am I missing on this query?

The Challenge says to return ModelName, VIN and StickerPrice. My query returns: ModelName, VIN and StickerPrice. The feedback says "Bummer. Your query isn't returning ModelName, VIN and StickerPrice." It works fine in the playground. What am I not seeing here?

SELECT md.ModelName, c.VIN, c.StickerPrice FROM Model AS md INNER JOIN Car AS c ON md.ModelId = c.ModelId GROUP BY md.ModelName;

Can you post a link to the challenge?

2 Answers

Steven Parker
Steven Parker
231,248 Points

:point_right: Your GROUP BY clause is restricting the result set.

The error message in the "bummer" message may be misleading.

By adding the GROUP BY, your result set will contain only one row for each model, but the challenge asked "For all cars in the database...". And the database contains more than one car for most models.

To get a row for each individual car, you don't need (or want) the GROUP BY.

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,143 Points

I guess it's another in a million+ lessons about not putting in more than one is tasked to put in to the code.