MySQL Query for book cost of a class

后端 未结 6 774
清酒与你
清酒与你 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条回答
  •  旧时难觅i
    2021-01-21 18:15

    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
    

提交回复
热议问题