在Microsoft SQL Server中:
我已经多次看过这个问题了,但看不到有人解决这个问题:
UPDATE theTable t1
SET t1.col2 =
(SELECT (10 * (col1 + col2))
FROM theTable t2
WHERE t1.busRelAccount = t2.busRelAccount
AND t2.rowName = 'POS'
)
WHERE t1.busRelAccount = t2.busRelAccount
AND t1.rowName = 'INVENTORY'
;
Run Code Online (Sandbox Code Playgroud)
有没有使用CURSOR解决这个问题的人并循环表?