I have a table in oracle which has 4 attributes with the following values
attribute_a attribute_b attribute_c attribute_d
abcd1 1 0
abcd1 2 1
abcd1 3 0
def1 1 1
def1 2 1
I want to update the attribute_d with 'logical AND' values into attribute_d depending on the values in attribute_c
ie for abcd1 the logical AND is 0. I want to update the table with values 0 for abcd1 in attribute_d
and for def1, I want to update the table with value 1 in attribute_d for def1. can I use MERGE to accomplish this and if anyone can give me a query greatly appreciated.
First off, I agree with @jarlh's comment about storing computed values.
Solution:
UPDATE [TableName]
SET attribute d = (CASE WHEN attribute_b = attribute c THEN 1 ELSE 0 END)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.