I have the table ACCOUNT
of structure as follow:
ACCOUNT_ID | ACCOUNT_STATUS|
004460721 | 2 |
042056291 | 5 |
601272065 | 3 |
I need to update the three rows at once using one SELECT
statement such that, the second column will be 5, 3, 2 respectively.
I used the following query but seems there is something missing
UPDATE ACCOUNT
SET ACCOUNT_STATUS = CASE
WHEN ACCOUNT_STATUS = '004460721' THEN 5
WHEN ACCOUNT_STATUS = '042056291' THEN 3
WHEN ACCOUNT_STATUS = '601272065' THEN 2
WHERE ACCOUNT_ID IN ('004460721','042056291','601272065')
My question, is this way correct? if no, can I use CASE WHEN
statement and how or I only have choice of using SUB-SELECT
to acheive that in one statement?
Kindly, notice this is for SQL ORACLE