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 Reporting with SQL Aggregate and Numeric Functions Calculating the Minimum and Maximum Values

Satyam garhewal
Satyam garhewal
326 Points

Why my query is not working, can you please help me out?

I have selected the rating column and taken out the average similar in the last query and it worked in the last query but here, I am doing everything according to the tutorial but still I am not getting the solution.

2 Answers

Mustafa Başaran
Mustafa Başaran
28,046 Points

Hi Satyam,

You are asked to calculate the min and max values of rating column from the reviews table with movie_id = 6 and alias these two as star_min and star_max , respectively.

Please check the column you have selected, make use of MIN() and MAX() functions, use the aliases mentioned and select the correct movie_id in your WHERE clause. Then, it should be fine.

SELECT MIN(rating) AS star_min, MAX(rating) AS star_max FROM reviews WHERE movie_id = 6;
Satyam garhewal
Satyam garhewal
326 Points

Thank you, Mustafa, now I get what I was doing wrong, I was taking out the average of rating that the question wasn't even asking for. The Query you gave is correct- Select MIN (rating) AS star_min, MAX (rating) AS star_max from reviews where movie_id = 6;