Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I am trying list the number of movies rated and the average rating for everyone named Smith. This what i have:
Select count(r.rating) as NumofRatings,avg(r.rating) as AverageRating, c.lname, c.fnamefrom ratings rinner join customers con c.customerid = r.customeridwhere c.lname = 'smith'group by r.rating;
This only brings up 5 records but there are 91 records of last name smith who have rated movies. The group by seems to be messing the results up can anyone help?
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-11-23 : 13:33:13
your statement doesnt make sense. you group by rating and again try to take sum & average. did you mean this?
Select count(r.rating) as NumofRatings,avg(r.rating) as AverageRating, c.lname, c.fnamefrom ratings rinner join customers con c.customerid = r.customeridwhere c.lname = 'smith'group by c.lname, c.fname