查询需要找到一个名为Yossi Cohen的客户,他购买了许多商品和购买金额(总和) 例如:Yossi Cohen买了三件物品,价值40谢克尔,我们想知道订单的数量。
示例:
namecustomer namemodel quantity sum
Yossi Cohen iphone6 3 120
我试着写这个:(不工作)
SELECT nameCustomer,
(SELECT idCustomer,nameCustomer,nameModel,idOrders,Quantity,
SUM(price*Quantity)AS OrderTotal
FROM Customers,OrdersItems,Products GROUP BY idOrders)
FROM Customer
where Customer = 'Yossi Cohen';
答案 0 :(得分:0)
这应该做的工作:
SELECT idCustomer,nameCustomer,nameModel,idOrders,Quantity
From Customer
Where sum=price*Quantity
AND Customer = 'Yossi Cohen';