如果制造和尺寸相同,则聚合抛光

时间:2016-06-09 03:41:54

标签: sql

表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  

如果制作和尺寸与抛光相同且粗糙应该聚合

1 个答案:

答案 0 :(得分:2)

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