我有一个名为material_line_item
的表格,在该表格中有3列1.item_master_id
2.received_quantity
和3.ordered_quantity
我想要一个查询来计算这两个字段中的所有数量(received_quantity` and `ordered_quantity
)基于item_master_id
。
答案 0 :(得分:4)
这应该有所帮助:
SELECT item_master_id, sum(received_quantity), sum(ordered_quantity) FROM material_line_item
GROUP BY item_master_id
答案 1 :(得分:1)
与上述解决方案相同,但已格式化:)
SELECT item_master_id ,Sum(received_quantity) Total_Received_Qty ,Sum(ordered_quantity) Total_Ordered_Qty FROM material_line_item GROUP BY item_master_id