Hello
If I understand, you are trying to create a table and insert values into it using SQL. However, the CASE
statements you provided are not valid SQL syntax. To update the values in the table based on certain conditions, you can use an UPDATE
statement with a CASE
expression. Here’s an example that should achieve the desired result:
CREATE TABLE table11 (
col1 CHAR,
col2 INT,
col3 INT
);
INSERT INTO table11 VALUES (1, 2, 3);
INSERT INTO table11 VALUES (2, 4, 6);
INSERT INTO table11 VALUES (3, 6, 9);
INSERT INTO table11 VALUES (4, 8, 12);
UPDATE table11
SET col2 = CASE
WHEN col1 = 2 THEN 0
WHEN col1 = 3 THEN 0
ELSE col2
END,
col3 = CASE
WHEN col1 = 1 THEN 0
WHEN col1 = 4 THEN 0
ELSE col3
END;
I hope this helps Alistair