Add values from Col 5 to values in col 6 and put them into col 7 in the SAME oracle Table
Posted on 2016-08-22
I have a table Alpha, it has col_1, Col_2, Col_3, Col_4, Col_5, Col_6, Col_7. The datatype in each column is number (10).
I want to add values in Col_5 with values in Col_6 and store the result in col_7 for each row in the table, taking into account NULL values in either column (Col_5, Col_6). We are adding numbers only. No data conversion. It could be a an update statement or Merge statement.
I tried this, but did not work.
Update Alpha set Col_7 = ((Select Case when col_5 = -1 or col_6 = -1 then -1
else col_5 + col_6