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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Ian Corritore](https://secure.gravatar.com/avatar/2d350906b1e272ff58d3981c3016cae1?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ian Corritore
4,740 PointsGroup, Joining, and Filter in SQL.
I am stumped on this segment: Like before, select the average "score" as "average", setting to 0 if null, by grouping the "movie_id" from the "reviews" table. Also, do an outer join on the "movies" table with its "id" column and display the movie "title" before the "average". Finally, filter out any "average" score over 2. Here is my code:
SELECT title, IFNULL(AVG(score).0) AS average FROM movies LEFT OUTER JOIN reviews ON movies.id = reviews.movie_id GROUP BY movie_id HAVING average < 2;
Where am I going wrong?
1 Answer
![bothxp](https://uploads.teamtreehouse.com/production/profile-photos/303042/micro_poley_2.jpg)
bothxp
16,510 PointsHi Ian,
My answer was:
SELECT title, ifnull(avg(score),0) as average
FROM movies left outer join reviews
ON movies.id = reviews.movie_id
GROUP BY movie_id
HAVING average <= 2;
It looks like you have a . instead of a , in the IFNULL
Dave McFarland
Treehouse TeacherDave McFarland
Treehouse TeacherHi Ian,
Your SQL code wasn't showing up correctly. I fixed it in your post. For the future, to put code in a forum post:
hit return to create a new line and type three back tick characters ```
hit return to create another new line and paste your HTML
hit return and add three more back tick characters: ``` The back tick character isn't the same as the single quote -- ' -- mark; the back tick is located on the same key as the ~ on most keyboards.
Also to add correct color highlighting add the name of the language after the back ticks like this: ```CSS. Here's what CSS should look like in a forum post: