Hi!
I’m wondering if someone can help me with a MySQL query for getting the top 10 best rated movies for an app I’m working on.
The DB fields are:
movie_id
movie_title
user_id
points
I’m trying with this:
$query = $this->db->query("SELECT MAX(SUM(points)/COUNT(user_id)) FROM movies LIMIT 10");
foreach ($query->result() as $row)
{
echo $row->movie_title;
}
but is not working, it shows the this error:
An Error Was Encountered
Error Number: 1111
Invalid use of group function
SELECT MAX(SUM(points)/COUNT(user_id)) FROM peliculas LIMIT 10
Can someone help me with this query? Thx
