1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| CREATE TABLE T_COALESCE_CLS
(CLS_VAL1 INT,
CLS_VAL2 INT,
CLS_VAL3 INT,
CLS_VAL4 INT,
CLS_VAL5 INT)
INSERT INTO T_COALESCE_CLS VALUES (1, 2, 3, 4, 5)
INSERT INTO T_COALESCE_CLS VALUES (NULL, 2, 3, 4, 5)
INSERT INTO T_COALESCE_CLS VALUES (NULL, 2, NULL, 4, NULL)
INSERT INTO T_COALESCE_CLS VALUES (NULL, NULL, NULL, 4, 5)
INSERT INTO T_COALESCE_CLS VALUES (NULL, NULL, NULL, NULL, NULL)
SELECT ISNULL(CLS_VAL1, 0) AS "IsNull",
COALESCE(CLS_VAL1, CLS_VAL2, CLS_VAL3, CLS_VAL4, CLS_VAL5, 0) AS "Coalesce"
FROM T_COALESCE_CLS |
Partager