SAP PAPM

SAP HANA SQL COALESCE Function

SAP HANA SQL COALESCE returns the first non-NULL expression from a specified list, specifies the expressions to return the first non-NULL expression from.

Example

CREATE ROW TABLE COALESCE_SQL (ID INT PRIMARY KEY, A REAL, B REAL);

INSERT INTO COALESCE_SQL VALUES(1, 100, 80);

INSERT INTO COALESCE_SQL VALUES(2, NULL, 63);

INSERT INTO COALESCE_SQL VALUES(3, NULL, NULL);

SELECT id, a, b, COALESCE (a, b*1.1, 50.0) “coalesce” FROM COALESCE_SQL;

Output Result 

ID A B coalesce
1 100 80 100
2 NULL 63 69.30000305
3 NULL NULL 50

Related Articles

Check Also
Close
Back to top button