## 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.

# On SQL Playground, Stage 3, Practice, how do I calculate the average movie rating and round it to 1 decimal place?

Hi,

In the Reporting in SQL class, I'm running into some issues with a question in the SQL Playground, Stage 3, Practice section. Here's the question:

Calculate the average rating for each movie and round it to one decimal place.

Here's my query:

SELECT AVG(rating) AS "average_rating", ROUND("average_rating", 1) FROM reviews;

Here's the results:

average_ rating = 3.8 ROUND(โaverage_ratingโ, 1) = 0

I think the average_rating is correct, but the rounded result is not. How do I calculate the average movie rating and round it to 1 decimal place?

Thanks,

Jan

## Did you want only one column?

In that case you'd want to enclose the average calculation inside the rounding function instead of listing them as two columns. So it might look like this:

```SELECT ROUND(AVG(rating), 1) AS average_rating FROM reviews;
```

Although it will be a bit hard to confirm with that data set since you apparently get the same result even without rounding.

Hi Steven,

I tried to put it in one column, but I got a syntax error. When I tried to combine the columns, I used AVG first and ROUND second [e.g. SELECT AVG(ROUND(rating, 1)) AS "average_rating" FROM reviews;]. It looks like I mixed up the order of the commands (should be ROUND, AVG instead of AVG, ROUND) and probably didn't get the parentheses placed correctly.

Originally, when I wrote this question, I listed "average_rating" = 3.8 on one line and ROUND(โaverage_ratingโ, 1) = 0 on the second line. It looks like the results were listed on one line instead. I agree. It will be hard to confirm with that data set.