我正在努力实现这个目标
VM Disk Capacity
VM1 Disk 1 100
VM1 Disk 2 40
VM1 Disk 1 100
VM1 Disk 2 40
VM2 Disk 1 45
VM2 Disk 1 45
VM3 Disk 1 30
VM3 Disk 2 30
结果应该是这样的
VM Capacity
VM1 140
VM2 45
VM3 60
答案 0 :(得分:0)
这有帮助吗?
SELECT a.column1, SUM(column3) FROM
(
SELECT DISTINCT column1, column2, column3 FROM tableA
) a
GROUP BY column1
答案 1 :(得分:0)
你去吧
http://sqlfiddle.com/#!6/285fe
SELECT a.vm, SUM(capacity)
FROM (
SELECT DISTINCT vm, DISK, capacity
FROM TEMP
) a
GROUP BY vm
答案 2 :(得分:0)
SELECT a.vm, SUM(capacity) as capacity FROM
(
SELECT DISTINCT vm, disk, capacity FROM test
) a
GROUP BY vm