如果两行具有相同的项目和位置,那么我有一个表如下,那么两个应该成为一行并给出总数qty
item location qty
a 1010 10
a 1020 5
a 1010 5
b 1010 2
b 1010 5
b 1020 1
c 1010 5
结果
item location qty
a 1010 15
a 1020 5
b 1010 7
b 1020 1
c 1010 5
答案 0 :(得分:0)
SELECT item, location, SUM(qty)
FROM xTable
GROUP BY item, location
答案 1 :(得分:0)
SELECT t.item, t.location, SUM(t.qty)
FROM test t
GROUP BY t.item, t.location
ORDER BY t.item, t.location