計算

2011-11-12 70 views
0

的所有值我有一個表order_product計算

enter image description here

我想計算從成本柱和數量的列,其中order_orderNumber = 1100

我如何做到這一切的價值觀?

+1

你到底由「計算」的意思。計算產品的總和? – xbonez

+0

是的,我想'SUM' :) –

回答

1

如果你的意思是總和,你可以這樣做:

SELECT product_id, SUM(quantity) AS totalQuantity, SUM(cost) AS totalCost 
FROM order_product WHERE order_orderNumber = 1100 
GROUP BY product_id