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

Databases

Calculation of sums is not correct -- Not sure what I'm doing!

You can see from the link here: https://teamtreehouse.com/library/reporting-with-sql/aggregate-and-numeric-functions/summing-values. This is the challenge I'm working on. I got really close, but then I kind of got confused and messed things up. Here is my code:

SELECT SUM(review) AS starman_total_ratings FROM reviews WHERE movie_id = 6 GROUP BY rating ORDER BY starman_total_ratings;

Thanks in advance!

~ Gabriel D

2 Answers

Steven Parker
Steven Parker
229,967 Points

You still have a few issues, some might be over-complication as a result of frustration:

  • the challenge wants you to sum the rating but you summed review.
  • you won't need GROUP BY since you're only reporting the aggregate
  • you also won't need ORDER BY since you'll only be returning one item

Ah, thanks yet again! I'm 14 right now, so frustration comes a tad easier than some more code-learned people! I got it cleaned up and passed the task.

Steven Parker
Steven Parker
229,967 Points

It's really great that you're getting into programming already (5 years earlier than me!). Happy coding!