Answer the question
In order to leave comments, you need to log in
How to edit a script?
Good day, for the task "write a query that allows you to increase by 1 all the values of the VALUE field of the table TABLE_A, if for a given row in the table TABLE_B there is an identical row and increase by 2 if such a row does not exist." I made a script, but it gives an error when compiling. Please tell me how to fix.
UPDATE TABLE_A
SET VALUE = VALUE + CASE
WHEN EXISTS(SELECT * FROM TABLE_B WHERE TABLE_B.ID = TABLE_A.ID)
THEN 1
ELSE 2
END
Answer the question
In order to leave comments, you need to log in
I figured it out, since there was a conflict of data types (in the first table INTEGER and in the second varchar ) I set INTEGER in two tables and the following script worked:
UPDATE TABLE_A
SET "VALUE" = "VALUE" + CASE
WHEN EXISTS(SELECT * FROM TABLE_B WHERE TABLE_B."VALUE" = TABLE_A."VALUE")
THEN + 1
ELSE + 2
END
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question