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

Write a query that totals up all ratings in the reviews table. Alias it as starman_total_ratings.

I had written the same query in community i could't get the result. i tried with various other query cannot answer though i used where condition instead of GROUP BY and HAVING i was getting an error neat the SELECT.

Umesh Ravji
Umesh Ravji
42,386 Points

Hi Anil, could you please show us what you have written?

1 Answer

Steven Parker
Steven Parker
231,140 Points

Be sure you have grouped your query elements properly.

Remember that any filter condition that applies to individual rows will go in a WHERE clause, and come before a GROUP BY. And any filter that applies to the aggregate value(s) will go after it in a HAVING clause.

To enable a more specific and accurate analysis, always show your complete code and provide a link to the course page.

can you send me the query for the question please. We are in movie database. there's a reviews table with the columns of id,movie_id,username,review and rating.

the movie "starman"has the id of 6. Write a query that totals up all ratings in the reviews table. Alias it as starman_total_ratings.

Steven Parker
Steven Parker
231,140 Points

Please give it your best "good faith" attempt, using the hints already given, and then post your code if you still need some help.