2016-06-09 46 views
0

表A都彙集在波蘭,如果品牌和大小相同

Make | Size  | Polish | Rough 
--------------------------------------------------------- 

VG | 2.00 up  | 2.45 | 2.7 
VG | 2.00 up  | 3.25 | 3.5 
VG | 1.00-1.99 | 1.20 | 1.30 
VG | 1.00-1.99 | 1.5 | 1.6 
AG | 0.30-0.49 | 0.35 | 0.40 
AG | 0.50-0.99 | 0.55 | 0.60 
AG | 0.50-0.99 | 0.65 | 0.70 

輸出

Make | Size  | Polish | Rough 
VG | 2.00 up  | 5.70 | 6.2 
VG | 1.00-1.99 | 2.70 | 2.90 
AG | 0.30-0.49 | 0.35 | 0.40 
AG | 0.50-0.99 | 1.20 | 1.30 

如果品牌和大小比拋光和粗糙同樣應該彙集起來

回答

2
select Make, Size, sum(Polish) as Polish, sum(Rough) as Rough 
from TableA 
group by Make, Size