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

Development Tools

Issue with Database grouping code challenge

The code challenge asks "Group all reviews by "movie_id" and get the average "score" and alias it as "average"

I enter ```SELECT movie_id, AVG(score) AS average FROM reviews GROUP BY movie_id

which should work, because it works when I use it in MySQL Workbench using the provided treehouse_movie_db

Strangely enough, entering this in the treehouse console, while flagged as incorrect, generates a table with the correct columns, however average scores show up with a 0 infront of them, ie 0.324 instead of 3.24 

Anyone know whats going on?

5 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hi there,

The answer you're looking for is - SELECT avg(score) as average FROM reviews GROUP BY movie_id;

It just asks you to average the scores, not select the movie_id next to the averages. It's just to show you can group by something and not select it aswell.

Regards
Andrew

Hi, Tyler Garrett :

Your input should've worked as well as mine, being a heavy SQL user:

SELECT reviews.movie_id, AVG(reviews.score) AS average FROM reviews GROUP BY reviews.movie_id; 

There does seem to be an issue with the challenge; I'll take steps to contact Treehouse Core Support Staff about this on your behalf to get to the bottom of this; there was a recent problem with challenges that may still be affecting this challenge.

Ok. Thanks for the quick response.

No problem; I too had correct averages outputted but still was marked wrong.

Being a completer of the course long ago and knowing it had a much better console, it seems that things are still being ironed out from the unexpected problems that affected the challenge system last week.

Any update on this issue? I've gone and done the rest of the track, I just need to pass these code challenges to clear the DB Foundations track.