oracle sql - update same table based on another attribute value -
i have table in oracle has 4 attributes 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 update attribute_d 'logical and' values attribute_d depending on values in attribute_c
 i.e. abcd1  logical , 0. want update table values 0 abcd1 in attribute_d
 , def1, want update table value 1 in attribute_d def1. can use merge accomplish , if can give me query appreciated.     
first off, agree @jarlh's comment storing computed values.
solution:
update [tablename] set attribute d = (case when attribute_b = attribute c 1 else 0 end)      
Comments
Post a Comment