例如,我需要将numOrdered
(11)乘以quotedPrice
(14.95),并且由于该行与下一行具有相同的orderNum
,我会添加产品到1和399的乘积,依此类推每个orderNum
。
| orderNum | partNum | numOrdered | quotedPrice |
| 12489 | ax12 | 11 | 14.95 |
| 12489 | bt04 | 1 | 399 |
| 12489 | bz66 | 3 | 300 |
| 12489 | cb03 | 5 | 170 |
| 12489 | cx11 | 1 | 60 |
答案 0 :(得分:0)
我想你只想要一个非常基本的聚合查询:
select ordernum, sum(numOrdered * quotedPrice)
from t
group by ordernum;