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

Lucas Hoelscher
Lucas Hoelscher
3,647 Points

Don't understand the syntax for these quesitons

Hi, I haven't been able to finish this quiz because I'm just not understanding the order of keywords. I've been following the video before the quiz and trying copy the parts that relate to the questions being asked in the quiz, but I haven't been able to pass yet. Does anyone have any answers to these quizzes so I can understand where I'm going wrong?

1 Answer

Daniel Markham
Daniel Markham
10,976 Points

I would agree with you that the question wording on this quiz was very difficult to work out ( I use SQL intensively for work and I had to give this a couple of tries). Here is the syntax I used for each of the parts:

select AVG(score) as average from reviews group by movie_id;

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

select movies.title as title,AVG(IFNULL(score,0))as average from movies left outer join reviews on movies.id=reviews.movie_id group by reviews.movie_id having IFNULL(AVG(score),0) <2;