Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.