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 Database Foundations SQL Calculating, Aggregating and Other Functions Grouping, Joining and Cleaning Up

Christian Damm
Christian Damm
26,486 Points

Who is buggy? Me or Code Chellenge

Hello,

on http://teamtreehouse.com/library/grouping-joining-and-cleaning-up I put in the correct query (I guess):

select avg(score) as average from reviews 
group by movie_id 
having average > 2;

But the Code Chellenge parser always comes with an error and strange evaluations like this:

average
0.28372E1
0.30732E1
0.38333E1

2 Answers

Stone Preston
Stone Preston
42,016 Points

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

we want to filter out (ie dont show) reviews with an average greater than 2. so we only want to select reviews with averages LESS than 2

your query is almost correct, just flip your > around to be <

select avg(score) as average from reviews 
group by movie_id 
having average < 2;