I just need a single MySQL line query for the following.
Lets say there are 2 simple tables: Class and Books<
Class
Books
select min(c.Name) as Name, sum(b.Price * c.Students) as Cost from Class c left join Books b on b.ClassId = c.ID where c.Students >= 31 group by c.ID