Databases SQL Reporting by Example Orientation: Selecting Data Listing Subjects

The first challenge should include GROUP BY

The first challenge should include GROUP BY because some subjects are repeated

4 Answers

Steven Parker
Steven Parker
177,563 Points

That'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;

I tried that first and no change then I tried GROUP BY and that worked. weird..

Steven Parker
Steven Parker
177,563 Points

Maybe a syntax issue? See the example I added to my answer.

Yes that was it. I would then use GROUP BY to order it

Steven Parker
Steven Parker
177,563 Points

Did you mean ORDER BY?

SELECT DISTINCT name FROM subjects ORDER BY name;

Yes silly me !