MySQL Query for book cost of a class

后端 未结 6 858
清酒与你
清酒与你 2021-01-21 17:39

I just need a single MySQL line query for the following.

Lets say there are 2 simple tables: Class and Books<

6条回答
  •  我在风中等你
    2021-01-21 18:12

       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
    

提交回复
热议问题