Good afternoon all,
I am trying to affect what i'm sure is a basic replace function on some of the values in the first column of a table dependent on the value of the second column. So if i run the simple SELECT shown below i get the following:
----SCRIPT----
SELECT Col_name_1, Col_name_2
FROM Table_Name
----Results----
Col_name_1 Col_name_2
13 0
23 0
44 1
47 1
50 0
Now say i wanted to replace the values in 'Col_name_1' to negative values if the value in the same row of 'Col_name_2' is 1. Giving the following result.
Col_name_1 Col_name_2
13 0
23 0
-44 1
-47 1
50 0
What would be the most efficient way to do this. I was thinking of using logic along the lines of if(Col_name_2=1,) then replace(col_name_1, '-&col_name_1') obviously the syntax of this is incorrect i was just wondering how i could produce a "conditional replace function" that will only affect certain rows of the results table dependent on condition.
Many thanks
Charlie