Home > Software design >  Update Column: Case With Concat
Update Column: Case With Concat

Time:05-07

I am have a blank column, it is called column_blank. I want to concat two other columns (concat1, concat2) and based on the concat value, add a value into column_blank. I am extremely green and appreciate your help.

This is what I am thinking. I am not too confident about the DECLARE statement

DECLARE DIRECTION CONCAT := (CONCAT1, CONCAT2);

INSERT INTO 
MYDATA_EXTRACT_DATA.COLUMN_BLANK

SELECT

  CASE COLUMN_BLANK
    
    WHEN (DIRECTION) IS '123456', THEN ('654321'),
    WHEN (DIRECTION) IS '789101', THEN ('654321'),
    ELSE '000'
  
  END CASE 
  
  FROM MYDATA_EXTRACT_DATA

CodePudding user response:

That's just an ordinary update statement:

update mydata_extract_data set
  column_blank = case when concat1 || concat2 in ('123456', '789101') then '654321'
                      else '000'
                 end;
  • Related