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 trialAndreas Gagnier Ruckert
10,352 PointsStumped on Grouping, Joining and Cleaning Database Challenge 1.
I keep getting an error message on this challenge, even though it returns a table with the averages down below. My code is:
SELECT movie_id, AVG(score) AS average FROM reviews GROUP BY movie_id;
Any help would be appreciated.
1 Answer
Ken Alger
Treehouse TeacherAndreas;
We are given a challenge prompt of: Group all reviews by "movie_id" and get the average "score" and alias it as "average".
Let's take a look, eh?
We need to get (SELECT
) the score data and average it (AVG(score)
), and call it "average" (AS average
). We need to obtain the data from (FROM
) a location (table name) and group all of these reviews by "movie_id" (GROUP BY movie_id
). If memory serves, this all resides in a table titled reviews
so that would be FROM
where we select it, correct?
Our code statement then would be:
SELECT AVG(score) AS average FROM reviews GROUP BY movie_id;
I think you were very close but were also choosing the movie_id field, which is not necessary for this particular task.
Happy coding,
Ken
Andreas Gagnier Ruckert
10,352 PointsThank you very much, I now see my error. That works better!
John Hebron
23,993 PointsThis was super helpful to me as well. Thank you!
Andreas Gagnier Ruckert
10,352 PointsAndreas Gagnier Ruckert
10,352 PointsThe challenge reads:
Group all reviews by "movie_id" and get the average "score" and alias it as "average".