计算列中的所有值

时间:2011-11-12 16:41:48

标签: php mysql

我有一张表order_product

enter image description here

我想计算成本列和数量列WHERE order_orderNumber = 1100

中的所有值

我该怎么做。?

1 个答案:

答案 0 :(得分:1)

如果你的意思是总和,你可以这样做:

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