Welcome to the Treehouse Community
Looking to learn something new?
Issues with grouping-joining-and-cleaning-up Quiz section
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?
"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 Watson8,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?