【发布时间】:2017-12-12 07:01:41
【问题描述】:
如何从上表中找到所有客户中最受欢迎的书? (cid = '客户 ID')?
我有
select Title, sum(c.quantity) from cart c group by c.ISBN;
这给了我以下结果
+-----------------------------------------+-----------------+ | Title | sum(c.quantity) | +-----------------------------------------+-----------------+ | Writing Skills | 5 | | Fundamentals of Database Systems | 2 | | Database Management Systems | 5 | | Data Mining, Practical Machine Learning | 4 | +-----------------------------------------+-----------------+
我知道mysql中的Max()函数可以达到我的目的,但是不知道Max()和Sum()一起实现。
谢谢!
【问题讨论】: