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 trialkevin hudson
Courses Plus Student 11,987 PointsThe first challenge should include GROUP BY
The first challenge should include GROUP BY because some subjects are repeated
5 Answers
Steven Parker
231,269 PointsThat's certainly one way to do it. An even easier way would be to use the DISTINCT
keyword:
-- Which subjects are taught at Jefferson Middle School?
SELECT DISTINCT name FROM subjects;
kevin hudson
Courses Plus Student 11,987 PointsI tried that first and no change then I tried GROUP BY and that worked. weird..
Steven Parker
231,269 PointsMaybe a syntax issue? See the example I added to my answer.
kevin hudson
Courses Plus Student 11,987 PointsYes that was it. I would then use GROUP BY to order it
Steven Parker
231,269 PointsDid you mean ORDER BY?
SELECT DISTINCT name FROM subjects ORDER BY name;
kevin hudson
Courses Plus Student 11,987 PointsYes silly me !
Jackson White
4,649 PointsI'm definitely quite late to answering this question, but I don't think you'll need to use GROUP BY or DISTINCT here. While there are repeating values in the Name columns, they are unique in that they are taught for different grade levels. For example, there are three instances of the Math value, but they're designated for grades 6, 7, and 8.