I need to update a table based on a value derived from case logic. That case logic is created using several other tables, such as this:
CASE
WHEN column = 'value'
THEN
COALESCE
(
CASE WHEN column = 'test1' THEN 'result' END,
CASE WHEN column = 'test2' THEN 'result' END
)
ELSE
column
END AS Derived_Column
FROM
table_a a
LEFT JOIN table_b b ON a.column = b.column
LEFT JOIN tabel_c c ON b.column = c.column
What I need to to do something like this:
UPDATE table SET column =
( SELECT column FROM table WHERE column = <CASE STATEMENT LOGIC>)
Somehow I need to updated the column in the table filtering on the the output of Derived_Column. So I need to check against a sub query or something of that nature.
Would anyone know how to do this?