我有一列SQL服務器:有條件地添加行和列
--------------------------------------------------------------
| Sl. No. | bal1 | bal2 | bal3 | status1 | status2 | status3 |
--------------------------------------------------------------
| 1 | 520 | 270 | 351 | 1 | 0 | 1 |
| 2 | 201 | 456 | 154 | 0 | 1 | 1 |
--------------------------------------------------------------
我想補充的行字段狀態值= 1在SQL Server
如。結果
--------------------
| Sl. No. | amount |
--------------------
| 1 | 871 | // bal1 + bal3 as the status1 and status3 is 1
| 2 | 610 | // bal2 + bal3 as the status2 and status3 is 1
--------------------
在此先感謝。
'CASE status1當1那麼bal1 ELSE 0 END + CASE狀態2當1那麼bal2 ELSE 0 END + CASE狀態3當1 TH EN bal3 ELSE 0 END' – 2014-10-20 03:36:05