Wednesday 10 December 2014

COALESCE operator


Assuming that you are calculating total salary by summing up salary and comm columns in emp table.

SELECT EMPNO,ENAME,SAL,COMM,

SAL+COMM  AS TOTAL_SAL,

SAL+COALESCE(COMM,0) AS TOTAL_SAL

FROM EMP


COALESCE function substitutes the value "0" when the comm is null.

It is similar to NVL fucntion.

No comments:

Post a Comment