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 Question

I'm stuck on the question below and was wondering if anyone could walk me through answering it.

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

I appreciate any help. Thanks.

1 Answer

hard to say without seeing the data you're working with, but I imagine you have a table that has multiple scores for each movie_id, so you'd want to use 'group by' so that you're getting the average score for each movie (or movie_id) instead of just an average for the whole set of scores. The keyword you need for aliasing is 'as' - you can read more about aggregate functions like avg() here: http://www.w3schools.com/sql/sql_func_avg.asp and 'group by' here: http://www.w3schools.com/sql/sql_groupby.asp (if those links don't work, just search for w3schools and sql)