MySQL Query for book cost of a class

后端 未结 6 772
清酒与你
清酒与你 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:08

    Something like this:

    select c.classId, sum(b.cost) as TotalCost,sum(c.students) as TotalStudents from books as b, class as c where b.classId = class.Id and c.Id = YourKnowClassId group by c.Id;
    

提交回复
热议问题