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

I can't figure this out!

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

My answer: SELECT movie_id AVG(score) AS average FROM movies GROUP BY movie_id

2 Answers

I think something like ...

SELECT AVG(score) AS average FROM reviews GROUP BY movie_id

... should do it.

Steve.

Aah, I was quering the wrong database.

I think it would be helpful if we are told what schema (databases and tables) are available to us. Often times in this course, I had to guess the name of the database in the challenges. Most of the times, it carries over from one challenge to another, but sometimes I forget, and then its annoying cause its like throwing the basketball into the dark hoping to find a basket somewhere, if you know what I mean...

Thanks for your answer.

I agree that there are some challenges like that. I found a few courses too - especially in the Rails track where the code gets updated, or databases get created with no instruction how to do that yourself. I initially found it mega-frustrating but did eventually get through the problems. Although the last course I took I did just give up as the tutor was just flipping through multiple files deleting stuff seemingly at random with no explanation why!

I guess it can't be perfect!

Steve Hunter, I am doing some rails courses too. I see exactly what you are saying.