按总和分组可以按相同的顺序排列。整体订单不能考虑。
示例表
order no meterial name consumption
001 abc 1200
001 abc 800
002 abc 750
预期输出
meterial name consumption
abc 2750
当前输出
material name consumption
abc 2000
abc 750
答案 0 :(得分:3)
可能是因为order_no
条款中有GROUP BY
(以及material_name
)。如果您想要每material
行一行,那么只需在material_name
中使用GROUP BY
列,例如:
SELECT material_name, SUM(consumption)
FROM your_table
GROUP BY material_name;
答案 1 :(得分:0)
如果您正在使用MySQL,我会尝试:
SELECT material_name, SUM(consumption) as consumption
FROM table
GROUP BY material_name;