0
我有一個MySQL表,它看起來是這樣的。
表:接收
+--------------+-----------+---------+---------+-------+
| DateReceived | ItemCode | QtyPack | QtyStan | PCS |
+--------------+-----------+---------+---------+-------+
| 2016-09-09 | DRY000004 | 30.00 | 0.00 | 24.00 |
| 2016-09-09 | DRY000007 | 60.00 | 0.00 | 12.00 |
| 2016-09-09 | DRY000010 | 90.00 | 0.00 | 1.00 |
| 2016-09-09 | DRY000011 | 100.00 | 0.00 | 1.00 |
| 2016-09-09 | DRY000012 | 1.00 | 0.00 | 12.00 |
| 2016-09-09 | DRY000012 | 1.00 | 0.00 | 12.00 |
+--------------+-----------+---------+---------+-------+
和表方差
+-----------+-----------+
| ItemCode | Receiving |
+-----------+-----------+
| DRY000004 | NULL |
| DRY000007 | NULL |
| DRY000010 | NULL |
| DRY000011 | NULL |
| DRY000012 | NULL |
| DRY000013 | NULL |
| DRY000014 | NULL |
| DRY000016 | NULL |
| DRY000017 | NULL |
| DRY000018 | NULL |
| DRY000019 | NULL |
| DRY000020 | NULL |
| DRY000021 | NULL |
| EQU000001 | NULL |
+-----------+-----------+
我的目標在這裏是在列表Receiving
傳輸之前獲取的QtyPack
* PCS
+ QtyStan
的總和:Variance
和這裏是我的代碼
UPDATE Variance VAR INNER JOIN receiving REv ON VAR.ItemCode = REV.ItemCode
SET VAR.Receiving = replace(REV.QtyPack, ',', '') * replace(REV.PCS, ',', '') + replace(REV.QtyStan, ',', '')
WHERE VAR.ItemCode = REV.ItemCode and REV.Status = 'Posted' AND rev.DateReceived between '2016-09-09' and
'2016-09-09';
請忽略where子句中的條件,但如果你想這就是是我的其他標準在Table:Receiving
即使代碼工作似乎有什麼不對我有相同ItemCode
接收有一個數據,那就是DRY000012
與1
QtyPack
要剪切的故事,總之,這裏是我的問題
我怎樣才能在表Variance
傳輸之前總結所有ItemCode
?例如DRY000012
在接收傳輸之前必須變爲24。
TYSM爲今後幫助
TYSM的幫助,但我做了一些改變 –
真的很棒的幫助,已批准 –