I just need a single MySQL line query for the following.
Lets say there are 2 simple tables: Class and Books<
Class
Books
SELECT c.Name, SUM(b.Price * c.Students) cost FROM Class c LEFT JOIN Books b ON b.ClassId = c.ID WHERE c.Students >= 31 GROUP BY c.ID