列出每个类别的客户以及该客户在给定类别中下的订单总数。在查询中显示三列:CategoryName、CustomerName 和 TotalOrders(即给定类别中给定客户的订单的价格 * 数量)。按 TotalOrders 降序排列此数据。
最佳答案
应该是这个...
select category, customer, sum(price*quantity) as TotalOrders
from yourTable
group by category, customer
order by TotalOrders desc;
关于mysql - 基于w3schools的sql查询问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35876815/