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

PHP

Issues with grouping-joining-and-cleaning-up Quiz section

Okay,

I'm in the grouping-joining-and-cleaning-up Quiz section and it is asking for :

"Like before, group reviews by "movie_id", get the average "score" as "average" and filter out any averages over 2."

I respond with SQL of:

""SELECT movie_id, avg(score) as average from reviews group by movie_id having average > 2;"

and the results are :

movie_id average 2 0.30732E1 3 0.38333E1 4 0.27E1 5 0.36154E1 8 0.29167E1

It works in MySQL Workbench just fine, but you cannot go forward in the quiz with incorrect results.

Any suggestions? What am I missing?

Mike

4 Answers

"Filter out any averages over 2" means that you don't want the averages over two. It's a little confusing in the wording. Just flip your > sign and you've got it.

Thank-you Ben. I did catch that after I sent the forum question. But even after correcting that issue, the results are still returning averages less than 1. If I run the same SQL against the DB in Workbench, it returns valid information, just not in the quiz application.

Vernon Watson
Vernon Watson
8,854 Points
SELECT movies.title, IFNULL(AVG(score),0) AS average 
FROM reviews RIGHT OUTER JOIN movies 
ON movies.id = reviews.movie_id 
GROUP BY movie_id HAVING average < 2;

That was a tough one!

for the first part of the exercise, there seems to be a lack of information.

The question is :

Group all reviews by "movie_id" and get the average "score" and alias it as "average".

I am using:

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

It dosen't work? any idea?