stored procedures - Tsql Column Comparision on Sample table and update rows -


i trying compare 2 columns in table 1 , update rows in same table 1.

sample table

table1 columns a, b ,c, d

a b c d ------- x 1 x 0 x 2 x 0  x 3 y 0 y 4 x 0 

if columns , c different need multiply 2 column b value , update in d column in same table.

required output

a b c d ------- x 1 x 1 x 2 x 2  x 3 y 6 y 4 x 8 

can 1 tsql query please ?

try this

update table1 set columnd = case when columna!=columnc columnb*2 else columnd end 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -