table T 如下
pix id code amount Amount1 weight cost tool
1 1 807 8 2 4.2 200 X1
2 2 807 8.4 400 X2
1 3 809 3 4 2.2 150 X1
2 4 809 8.8 600 X4
3 5 809 X2
1 6 810 6 3 3.2 160 X3
2 7 810 9.6 480 X4
3 8 810 X2
...
要得到如下结果:
Amount1 Weight Cost
9 26.8 1480
结果中的数据来源如下:
Amount1 = sum(T.Amount1)
Weight = 8.4+ 8.8+ 9.6 ,也就是相同T.code的最大T.weight只和,其中:大T.weight = T.Amount1 * 小T.Weight
cost = 取相同T.Code的最大T.Cost之和,数据来源与Weight雷同
不知道说清楚没有,请大侠伸手