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 Reporting with SQL Aggregate and Numeric Functions Counting Groups

Having trouble with Task 2 of Challenge

Hi, I am currently trying to crack this task but with no avail. I see that it tells me to count the unique genres and alias it as total_genres. This is the input I am trying out with no success:

SELECT DISTINCT genre, COUNT(*) AS total_genres FROM books GROUP BY genre

Am I nearly there, or am I missing a step? Please let me know so I can figure out what the question is asking me. Thanks!

1 Answer

Some hints

  • you are only selecting one column in this challenge
  • syntax COUNT([ALL | DISTINCT] expression);
  • you don't need a group by

Thanks for the hints. I eventually figured it out after trying many different answers before you posted this comment. At the same time, your help is very much appreciated. I'm sure it will help others out there who are lost on this particular task like I was.