查询需要找到一个名为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';
最佳答案
这应该做的工作:
SELECT idCustomer,nameCustomer,nameModel,idOrders,Quantity
From Customer
Where sum=price*Quantity
AND Customer = 'Yossi Cohen';